RE: [PHP]REPOST: DB logic help...

From: Date: Tue, 31 Jul 2001 15:57:25 +0000
Subject: RE: [PHP]REPOST: DB logic help...
Groups: php.general 
Request: Send a blank email to php-general+get-60439@lists.php.net to get a copy of this message
What about something like: <?php $sql_bands = "SELECT Link FROM Table WHERE Category='band'"; $sql_sites = "SELECT Link FROM Table WHERE Category='site'"; $sql_other = "SELECT Link FROM Table WHERE Category='other'"; $query_bands = mysql_query($sql_bands); $query_sites = mysql_query($sql_sites); $query_other = mysql_query($sql_other); echo "<table>"; echo "<tr><td>Bands</td><td>Sites</td><td>Other</td></tr>"; do { $data = false; echo "<tr>"; if ($row_bands = mysql_fetch_array($query_bands)) { echo "<td>". $row_bands["Link"]. "</td>"; $data = true; } else { echo "<td>&nbsp;</td>"; } if ($row_sites = mysql_fetch_array($query_sites)) { echo "<td>". $row_sites["Link"]. "</td>"; $data = true; } else { echo "<td>&nbsp;</td>"; } if ($row_other = mysql_fetch_array($query_other)) { echo "<td>". $row_other["Link"]. "</td>"; $data = true; } else { echo "<td>&nbsp;</td>"; } echo "</tr>"; } while ($data == true); echo "</table>"; ?> It's untested, and fairly inelegant in that you get an empty row at the bottom, so you could count the rows for each set beforehand as part of the SQL instead of using $data as I have - but it may be a good starting point. HTH Jon -----Original Message----- From: Chris Cocuzzo [mailto:cuzo@mediaone.net] Sent: 31 July 2001 16:36 To: php-general@lists.php.net Subject: [PHP]REPOST: DB logic help... hey- I have a few pages on my website which need to be divided up into different columns and rows based on a category in a table. for example, on a links page, I have three different columns, one for bands, one for sites, and one for other things. I'm storing those things in the table with a category field, so that when I output the data, it goes to the right place. However I'm a little unsure of the actual code to do this... can someone lend me an example or give me some ideas? thanks chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#60439) next »