AaaDee wrote:Because i am getting the details from the database, this makes my problem a little bit difficult.
On the page where it displays, Beckham Man UTD, Owen Liverpool, Henry Arsenal. It doesnt actually say there names,
the code is
echo "
<tr>
<td>Player</td>
<td>Club</td>
</tr>";
while ( $row = mysql_fetch_array( $sql_result ) )
{
$player = $row["player"];
$club = $row["club"];
echo "
<tr>
<td>$player</td>
<td>$club</td>
</tr>";
So this get all the players and clubs in the database. So i dont actually say player club three times, just once.
im looking for something like
if $num_rows = number of rows in DB
then insert * into table
How would i go about this please.
Cheers
Hello my young little friend!
I'm propose you create function what will be do some operations with array, something like that:
- Code: Select all
$str_array = array("Beckham"-> "Man UTD", "Owen" -> "Liverpool", "Henry" -> "Arsenal");
# SQL add/remove function
function do_sql($str_array, $actions)
$count_act = count($str_array);
if ($action == "add")
{
for ($i=0 $i=>$count_act $i++)
{
[i]actions for add value and key to DB[/i]
}
}
elseif ($action == "remove"
{
[i]I think that you understand that need to do[/i]
}
Try in next time use function for simlify your code. It's easy. Good luck!
:wink: