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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.