Jump to content

while not looping


erron

Recommended Posts

i have this bit of code which is supposed to do a while loop of rows from a database then inside that does a while loop of columns, so its basically creating a html table of dynamic data from mysql.

 

the column loop works fine, but the row one isnt, it only goes through and echos out the first row then stops.

 

ive spent hours now trying to see why and i cant see it hence my call for help.

 

$totalrows = 4;
$columns = 5;
$columncount = 1;
$rowcount = 1;

echo "<table>";
while ($rowcount <= $totalrows) {
echo "<tr>";
$sql = "SELECT * FROM ville_map WHERE id = '$rowcount'";
$sql_result = mysql_query($sql, $connection); 
while ($row = mysql_fetch_array($sql_result)) { 
$c1 = explode(',', $row["c1"]);
$c2 = explode(',', $row["c2"]);
$c3 = explode(',', $row["c3"]);
$c4 = explode(',', $row["c4"]);
$c5 = explode(',', $row["c5"]);

while ($columncount <= $columns) {
$arraynum = ${'c'.$columncount};
 if ($arraynum[2] > 0) { $playerimage = '<img src="images/player' .$arraynum[2]. '.png"'; } else { $playerimage = ""; }
echo '<td background="images/' .$arraynum[0]. '.jpg" width="50" height="50">' .$playerimage. '</td>' ;
$columncount++;
}
}
echo "</tr>";
$rowcount++;
}
?>
</table>

 

any help would be much appreciated.

Link to comment
https://forums.phpfreaks.com/topic/222963-while-not-looping/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.