A little OT but i think it is important :
I really would not write this code like this .
You are making too many queries to the database . If u have 100 rows in first
table and 200 rows returned from second query , you make 100*200 queries to
the database !
Try using SQL Joins. Like this :
<?php
$query ="select * from cforum cf INNER JOIN scforum";
$res=mysql_query($query);
while ($line=mysql_fetch_array($res)){
?>
<table width="94%" border="-1" bordercolor="black" cellspacing="1"
cellpadding="0" align="center"> <tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0"
bgcolor="#ff6600"> <tr>
<td><font face="tahoma" size="1" color="white"><?php echo("<font face =tahoma
color=black size=1><b>$line[cname];</b></font><br>");
?></font></td> <td align="right"><font face="tahoma" size="1"
color="white">Forum Mods Will Go Here</font></td> </tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="98%" border="0" cellspacing="2" cellpadding="0"
align="center"> <tr>
<td><font face="tahoma" color="black" size="1">
<?php echo("<font face =tahoma color=black size=1><b>--> Topic Name:
</b>$line[scname] <br> <b>--> Topic Description:</b> line[scdesc]<br>"); ?>
</td>
</tr>
</table>
</td>
</tr>
</table><br>
<?php
}
You may want to use LEfT Join ..
This way you will make just ONE query to the database
On Monday April 3 2006 06:31, benifactor wrote:
> i am creating a forum and i am having trouble getting the database
> information in to an html table
>
> i believe it has somthing to do with the placement of the while loops
> because they repeat the segment of code over untill the statment returns
> false, thus adding extra html.. you guys are the experts so if you could
> help i would appreaciate it. i will give you the code and an example of how
> its shows up and then how i need it to show up and if you could point me in
> the right direction it would be awsome...
>
>
> //code
> <?
> $query = mysql_query("select * from cforum");
> while ($query1 = mysql_fetch_array($query)) {
> $lid = $query1[id];
>
> $query2 = mysql_query("select * from scforum where cfid = '$lid'");
> while ($query3 = mysql_fetch_array($query2)) {
>
> ?>
> <table width="94%" border="-1" bordercolor="black" cellspacing="1"
> cellpadding="0" align="center"> <tr>
> <td>
> <table width="100%" border="0" cellspacing="0" cellpadding="0"
> bgcolor="#ff6600"> <tr>
> <td><font face="tahoma" size="1" color="white"><?php echo("<font face
> =tahoma color=black size=1><b>$query1[cname];</b></font><br>");
> ?></font></td> <td align="right"><font face="tahoma" size="1"
> color="white">Forum Mods Will Go Here</font></td> </tr>
> </table>
> </td>
> </tr>
> <tr>
> <td>
> <table width="98%" border="0" cellspacing="2" cellpadding="0"
> align="center"> <tr>
> <td><font face="tahoma" color="black" size="1">
> <?php echo("<font face =tahoma color=black size=1><b>--> Topic Name:
> </b>$query3[scname] <br> <b>--> Topic Description:</b>
> $query3[scdesc]<br>"); ?>
>
> </td>
> </tr>
> </table>
> </td>
> </tr>
> </table><br>
>
>
>
> <?
> }
> }
>
> ?>
>
> //end code
>
> //here is how it displays
>
> General;
> Forum Mods Will Go Here
>
> --> Topic Name: General
> --> Topic Description: blagh l adsklhdfkhadklfhaklsdhf sdhlkh
>
>
>
>
>
> Other;
> Forum Mods Will Go Here
>
> --> Topic Name: Other
> --> Topic Description: sdfdsjl;asdf
>
>
>
>
>
> Other;
> Forum Mods Will Go Here
>
> --> Topic Name: Another Other
> --> Topic Description: sdafkasdhkdhas
>
>
>
>
>
> other;
> Forum Mods Will Go Here
>
> --> Topic Name: yet another other
> --> Topic Description: Talk about all aspects of other. oh wait
> There is another forum just for that!
>
>
>
>
>
> Bug Reports;
> Forum Mods Will Go Here
>
> --> Topic Name: Web Site Bug Reports
> --> Topic Description: Report bugs here. Please include
> information like, how the problem was encountered, the nature of the bug
> e.x. Spelling error on the forum page". Please give us steps on how to
> re-create the bug so we can fix it.
>
>
>
>
> // see this looks ok, but the 'others' should be grouped together....
>
> like this
> Other; forum Mods Will Go Here
> --> Topic Name: Another Other
> --> Topic Description: sdafkasdhkdhas
>
> --> Topic Name: Other
> --> Topic Description: sdfdsjl;asdf
>
>
> --> Topic Name: yet another other
> --> Topic Description: Talk about all aspects of other.
> oh wait There is another forum just for that!
>
>
>
>
> if you get what i mean and can offer any help i would appreaciate it thank
> you in advance!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php