mysql_fetch_array "removes" my html
Posted: Wed Dec 21, 2011 10:06 am
Hey guys
I'm kind of new to php and coding, but i am trying to create some thing like a forum. the problem for me is that in the page that shows all the topics (i'm calling it guides, cause it's supposed to be a site for guides), the topics won't show.
here is my code:
the stuff that won't show is the html that is surrounded by the mysql_fetch_array.
what did i do wrong, and how can i fix it?
I'm kind of new to php and coding, but i am trying to create some thing like a forum. the problem for me is that in the page that shows all the topics (i'm calling it guides, cause it's supposed to be a site for guides), the topics won't show.
here is my code:
Code: Select all
<?php
//open database
$connect = mysql_connect("****","****","*****") or die("couldn't connect!");
mysql_select_db("******") or die("couldn't find db");
// Order result by descending
$sql = "SELECT * FROM $guide ORDER BY id DESC";
$result=mysql_query($sql);
?>
<table width="900px" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td>
<td width="53%" align="center" bgcolor="#E6E6E6"><strong>guide</strong></td>
<td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td>
<td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td>
<td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)) {
?>
<tr>
<td bgcolor="#FFFFFF"><?php echo $rows['id']; ?></td>
<td bgcolor="#FFFFFF"><a href="view_guide.php?id=<?php echo $rows['id']; ?>"><?php echo $rows['guide']; ?></a><BR></td>
<td align="center" bgcolor="#FFFFFF"><?php echo $rows['view']; ?></td>
<td align="center" bgcolor="#FFFFFF"><?php echo $rows['reply']; ?></td>
<td align="center" bgcolor="#FFFFFF"><?php echo $rows['datetime']; ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="5" align="right" bgcolor="#E6E6E6"><a href="create_guide.php"><strong>Create New Guide</strong> </a></td>
</tr>
</table>what did i do wrong, and how can i fix it?