Jump to content


Photo

Help - Forums


  • Please log in to reply
No replies to this topic

#1 lancey10

lancey10
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 21 March 2006 - 05:58 AM

Ok so i have a project that im trying to do and it is creating a forum (NO i dont want to use already made ones cuz im trying to make my own lol)
here is what i got....
<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="forum_question"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name ORDER BY id DESC";
// OREDER BY id DESC is order result by descending
$result=mysql_query($sql);
?>


<?php
while($rows=mysql_fetch_array($result)){ // Start looping table row
?>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td width="6%" align="center" bgcolor="#E6E6E6">&nbsp;</td>
<td width="53%" align="center" bgcolor="#E6E6E6"><div align="left"><strong><? echo $rows['Title']; ?></strong></div></td>
<td width="15%" align="center" bgcolor="#E6E6E6">&nbsp;</td>
<td width="13%" align="center" bgcolor="#E6E6E6">&nbsp;</td>
<td width="13%" align="center" bgcolor="#E6E6E6">&nbsp;</td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td>
<td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['reply']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td>
</tr>

<?php
// Exit looping and close connection
}
mysql_close();
?>
<tr>
<td colspan="5" align="right" bgcolor="#E6E6E6"><a href="create_topic.php"><strong>Create New Topic</strong> </a></td>
</tr>
</table>
Now for the Topic Title, i onlu want it to show ONCE (instead of repeating when there is another row added) how do i do that?
and for the topics, how do i make it so lets say if catgorytype=1 then ONLY display those rows?





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users