Looping information into a table
| From: | benifactor | Date: | Mon, 03 Apr 2006 03:31:58 +0000 |
| Subject: | Looping information into a table | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-233096@lists.php.net to get a copy of this message | ||
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!