Advertisement
Guest User

Untitled

a guest
May 18th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. <?php
  2. include "config.php";
  3.  
  4. $host="$mysqlhost";
  5. $username="$mysqluser";
  6. $password="$mysqlpass";
  7. $db_name="$mysqldb";
  8. $tbl_name="forum_question";
  9.  
  10. // Connect to server and select databse.
  11. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  12. mysql_select_db("$db_name")or die("cannot select DB");
  13.  
  14. $sql="SELECT * FROM $tbl_name ORDER BY id DESC";
  15. // OREDER BY id DESC is order result by descending
  16. $result=mysql_query($sql);
  17. ?>
  18. <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
  19. <tr>
  20. <td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td>
  21. <td width="53%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td>
  22. <td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td>
  23. <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td>
  24. <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td>
  25. </tr>
  26.  
  27. <?php
  28. while($rows=mysql_fetch_array($result)){ // Start looping table row
  29. ?>
  30. <tr>
  31. <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td>
  32. <td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></td>
  33. <td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td>
  34. <td align="center" bgcolor="#FFFFFF"><? echo $rows['reply']; ?></td>
  35. <td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td>
  36. </tr>
  37.  
  38. <?php
  39. // Exit looping and close connection
  40. }
  41. mysql_close();
  42. ?>
  43. <tr>
  44. <td colspan="5" align="right" bgcolor="#E6E6E6"><a href="create_topic.php"><strong>Create New Topic</strong> </a></td>
  45. </tr>
  46. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement