i have created a loop script when it loops through create a table and sets up a zig zig to show pictures in a table, but i need to configure the script so if there is a odd number of products to display it want keep comming up with a error trying to display the last product which is not there. teh code i have used so far is
<?php
// create connection
$username = "";
$password = "";
$server = "";
$db_name = "ahc";
$connection = mysql_connect ("$server","$username", "$password") or die ("couldn't connect to Server.");
//select database
$db = mysql_select_db("$db_name", $connection) or die ("Couldn't select databse.");
//create sql statement
$sql = "SELECT imagename
FROM IMAGES
";
$result = mysql_query($sql, $connection) or die ("Coludn't execute query.");
$num_rows = mysql_num_rows($result);
$a = 1;
//looping part of the script
while($row = mysql_fetch_array($result)) {
$data[] = $row['imagename'];
}
echo "<table width =\"250\" border=\"1\" align=center>\n ";
for($i = 0; $i < $num_rows; $i++) {
echo "<tr><td>\n";
echo "$data[$i]</td></tr>\n";
$i++;
echo "<tr><td></td><td>$data[$i]</td>\n";
echo "</tr>\n";
}
?>
so i need to put something in the loop to check if there is another product , move to teh next rox and display and start teh loop again or if there is not a next row to display, jump out of the loop and thats it.
btw i'm a newbie at this