Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. <?php
  2. $host="localhost"; // Host name
  3. $username="root"; // Mysql username
  4. $password=""; // Mysql password
  5. $db_name="website_features"; // Database name
  6. $tbl_name="thread"; // 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. <html>
  17. <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
  18. <tr>
  19. <td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td>
  20. <td width="53%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td>
  21. <td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td>
  22. <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td>
  23. <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td>
  24. </tr>
  25. </html>
  26.  
  27. <?php
  28. while($rows=mysql_fetch_array($result)){ // Start looping table row
  29. ?>
  30. <html>
  31. <tr>
  32. <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td>
  33. <td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></td>
  34. <td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td>
  35. <td align="center" bgcolor="#FFFFFF"><? echo $rows['reply']; ?></td>
  36. <td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td>
  37. </tr>
  38. </html>
  39.  
  40. <?php
  41. // Exit looping and close connection
  42. }
  43. mysql_close();
  44. ?>
  45. <html>
  46. <tr>
  47. <td colspan="5" align="right" bgcolor="#E6E6E6"><a href="createtopic.php"><strong>Create New Topic</strong> </a></td>
  48. </tr>
  49. </table>
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement