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:[EMAIL PROTECTED]]
Sent: 31 July 2001 16:36
To: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to