Jump to content

Need help with counting data and echo after (multiple column)


pneudralics

Recommended Posts

I'm trying to learn how to display data results in multiple column. Can't seem to get php to echo <tr> and </tr> after counting certain amount of data.

 

//Retrieve gallery info
$galleryselect = "SELECT * FROM gallery ORDER BY id ASC";
//Count results
$count_gallery_result = mysql_query($galleryselect);
//Get counted results
$count_gallery = mysql_num_rows($count_gallery_result); 

if ($galleryresult = mysql_query ($galleryselect)) {
while ($row = mysql_fetch_array ($galleryresult)) {
$gallery = $row['image'];
?>
<?php
if ($count_gallery == 3) {
echo '<tr>';
}

echo "<td>$gallery</td>";

if ($count_gallery == 0) {
echo '</tr>';

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.