Advertisement
Guest User

Untitled

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