Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.52 KB | None | 0 0
  1. <?php
  2. $host="localhost"; // Host name
  3. $username="tryingthis_tryingthis"; // Mysql username
  4. $password="haven505"; // Mysql password
  5. $db_name="tryingthis_kusa"; // Database name
  6. $tbl_name="kusa_enter"; // 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="59%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td>
  20. <td width="10%" align="center" bgcolor="#E6E6E6"><strong>Username</strong></td>
  21. <td width="25%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td>
  22. </tr>
  23.  
  24. <?php
  25. while($rows=mysql_fetch_array($result)){ // Start looping table row
  26. ?>
  27. <tr>
  28. <td bgcolor="#FFFFFF"><?=$rows['id']?></td>
  29. <td bgcolor="#FFFFFF"><a href="view_thread.php?id=<? echo $rows['id']; ?>"><? echo $rows['subject']; ?></a><BR></td>
  30. <td align="center" bgcolor="#FFFFFF"><? echo $rows['name']; ?></td>
  31. <td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td>
  32. </tr>
  33.  
  34. <?php
  35. // Exit looping and close connection
  36. }
  37. mysql_close();
  38. ?>
  39. <tr>
  40. <td colspan="4" align="right" bgcolor="#E6E6E6"><strong><a href="newpost.php">Create New Topic</a></strong></td>
  41. </tr>
  42. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement