I have the following function which works well as far as it goes:
function clothtable($brand, $clothgroup){
$query = "SELECT extorint, thumb, popup FROM Web_images WHERE brand = '$brand' AND clothgroup = '$clothgroup' ORDER BY id" ;
$result = mysql_query($query) or die ("Error in query: $query. " .
mysql_error());
// count number of rows in database
$row_count = mysql_num_rows($result);
//check if there is a remainder after rows divided by 6
$remainder=$row_count%6;
//no of extra cells required to make up last row
$extracells=6-$remainder;
echo $clothgroup;
echo "<table>\n<tr>\n";
while($row = mysql_fetch_array($result))
{
if ($i && $i%6==0 )
echo "</tr>\n<tr>\n";
echo "<td>". $row['thumb']." ".$row['popup']."</td>\n";
$i++;
}
if ($extracells >0)
echo "<td colspan=".$extracells."> </td>\n";
echo "</tr>\n</table><br>\n";
}
clothtable("Somebrand", "F30");
I would very much like to call up the first row value of extorint from the Web_images MySQL table -so I could change
echo $clothgroup;
to
echo $clothgroup." ".$extorint;
but leave the other values in the first row of the array available for subsequent use in the while loop.
I guess I could open the database within the function, extract my value - then to re-initialise the array close MySQL, then reopen it to get going again. But that does seem really messy. Is there another way I could do this?
extorint is always the same value within the table range, and needs to be extracted before the html table is generated.