Re: REPOST: DB logic help...
| From: | Chris Cocuzzo | Date: | Wed, 01 Aug 2001 16:52:03 +0000 |
| Subject: | Re: REPOST: DB logic help... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-60700@lists.php.net to get a copy of this message | ||
hey-
ok, so I've worked on my problem a bit, and here's what I came up, and note
this is the whole page.
<?php
include("/home/fplg/lib/functions.php");
include("/home/fplg/db/db_config.php");
$conn = db_connect("fplg");
$bandquery = "SELECT linkid,title FROM links WHERE cat='band'";
$sitequery = "SELECT linkid,title FROM links WHERE cat='site'";
$miscquery = "SELECT linkid,title FROM links WHERE cat='misc'";
$bandresult = mysql_query($bandquery,$conn);
$siteresult = mysql_query($sitequery,$conn);
$miscresult = mysql_query($miscquery,$conn);
header_start("FPLG:Links");
?>
<table width="692" cellspacing="0" cellpadding="0">
<tr align="center">
<td width="230" bgcolor="#ff6600" align="center">
<font face="verdana,arial" size="2"
color="#ffffff">Bands</font>
</td>
<td width="230" bgcolor="#ff6600" align="center">
<font face="verdana,arial" size="2"
color="#ffffff">Sites</font>
</td>
<td width="230" bgcolor="#ff6600" align="center">
<font face="verdana,arial" size="2"
color="#ffffff">Other</font>
</td>
</tr>
<tr align="center">
<td width="230" bgcolor="#a9a9a9" align="center">
<?php
while($band_data = mysql_fetch_array($bandresult));
{
?>
<a href="/jump.php?linkid=<?php echo $band_data["linkid"];?>"
class="hov1" target="_new"><font size="2"
face="verdana,arial"
color="WHITE"><?php echo $band_data["title"];?></font></a>
<br><br>
<?php
}
?>
</td>
<td width="230" bgcolor="#a9a9a9" align="center">
<?php
while($site_data = mysql_fetch_array($siteresult));
{
?>
<a href=/jump.php?linkid=<?php echo $site_data["linkid"];?>"
class="hov1" target="_new"><font size="2"
face="verdana,arial"
color="WHITE"><?php echo $site_data["title"];?></font></a>
<br><br>
<?php
}
?>
</td>
<td width="230" bgcolor="#a9a9a9" align="center">
<?php
while($misc_data = mysql_fetch_array($miscresult));
{
?>
<a href="/jump.php?linkid=<?php echo $misc_data["linkid"];?>"
class="hov1" target="_new"><font size="2"
face="verdana,arial"
color="WHITE"><?php echo $misc_data["title"];?></font></a>
<br><br>
<?php
}
?>
</td>
<td width="230" bgcolor="#a9a9a9" align="center">
</tr>
</table>
</body>
</html>
this is supposed to display link information from my db in three columns,
one for bands, one for sites, and one for misc. only problem is that it's
not displaying correctly, as you can see: www.fplg.net/links.php
any ideas on what the problem is?
chris
----- Original Message -----
From: Jon Haworth <jhaworth@witanjardine.co.uk>
To: 'Chris Cocuzzo' <cuzo@mediaone.net>; <php-general@lists.php.net>
Sent: Tuesday, July 31, 2001 11:57 AM
Subject: RE: [PHP]REPOST: DB logic help...
> 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> </td>";
> }
> if ($row_sites = mysql_fetch_array($query_sites)) {
> echo "<td>". $row_sites["Link"]. "</td>";
> $data = true;
> } else {
> echo "<td> </td>";
> }
> if ($row_other = mysql_fetch_array($query_other)) {
> echo "<td>". $row_other["Link"]. "</td>";
> $data = true;
> } else {
> echo "<td> </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
>
> --
> 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
>