469,906 Members | 2,160 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,906 developers. It's quick & easy.

how to reply to a topic for simple thread forum (PHP)

Hi! I tried creating a forum manually using PHP and succeeded in posting topics and creating new topics, the new topics can be inserted into database, but cant retrieve from database and display this new topic out, i don;t where is the problem of it. I am also unable to figure out how to reply to individual topics.

The topic code is as follows:
<paste code here>
Expand|Select|Wrap|Line Numbers
  1. $sql = "SELECT * FROM box ORDER BY time DESC LIMIT 10 ";
  2.     $result = mysql_query($sql) or die(mysql_error());
  3.     while ($row = mysql_fetch_array($result)) {
  4.         $message = $row['message'];
  5.         $title=$row['title'];
  6.         // replace smileys by images
  7.         $sql2 = "SELECT * FROM smileys";
  8.         $result2 = mysql_query($sql2) or die(mysql_error());
  9.         while ($row2 = mysql_fetch_array($result2)) {
  10.             $message = str_replace($row2['text'], "<img src = 'images/".$row2['image']."'>", $message);
  11.         }
  12.         $age = time() - $row['time'];
  13.         if ($age < 60) {
  14.             $bgcolor = "#FF0000";
  15.         } elseif ($age < 300) {
  16.             $bgcolor = "#FF4444";
  17.         } elseif ($age < 1200) {
  18.             $bgcolor = "#FF8888";
  19.         } elseif ($age < 2400) {
  20.             $bgcolor = "#FFBBBB";
  21.         } else {
  22.             $bgcolor = "#FFFFFF";
  23.         }
  24.  
  25.         echo "<table width='100%'  border='1' cellspacing='2' cellpadding='0'>";
  26.         echo "<tr><th width='20%'>Topic Title</th>
  27.         <th><div align='right'>
  28.     <p align='left'>$title</p>
  29.     </div></th>";
  30.         echo"<tr><th width='20%'scope='col' bgcolor=";
  31.         echo $bgcolor;
  32.         echo ">";
  33.         echo "<div align='center'><img src='images/mact.jpg' align='center'></div>";
  34.         echo"<br>";
  35.         echo "Time: ".date("d/m H:i", $row['time'])." ";
  36.         echo"<br>";
  37.         echo "<i>";
  38.  
  39.         echo "User Name:".$row['name'];
  40.  
  41.         echo"</th>";
  42.         echo"<th width='80%' align='left'>";
  43.         echo "</i> <br>";
  44.  
  45.         echo $message;
  46.         echo"</th></tr>";
  47.         echo "<tr><th>&nbsp;</th>
  48.         <th><div align='right'>
  49.     <p align='right'><img src='images/reply.JPG' width='14' height='16'><a href='index.php'>reply</a>&nbsp;<img src='images/quate.JPG' width='16' height='16'><a href='file:///C|/xampp/htdocs/fyp/forum/Tournaments.php'> Quate</a></p>
  50.     </div></th>
  51.         </table>";
  52.  
[Please use CODE tags when posting source code. Thanks! --pbmods]

this is the code to retrieve the new posted topices and display new posted topics, but somehow don;t know where is wrong, the new posted topic cant be displayed.

so how should i solve this problem and how should i do reply form page?


Is any1 able to help me out please...? THANKS in advance for your help :)
Jun 27 '07 #1
1 1892
nathj
938 Expert 512MB
It might be helpful to have some idea of the data structure you are using, as we are really talking about specific data retreival. Unless I have misunderstood the question, in which case my apologies, perhaps you could provide further explanation.

Also , it makes the post easier to read if you put the code tags around the code you are posting.

Let me know and I'll try to help.
Cheers
Nathan
Jun 27 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.