Advertisement
Guest User

Untitled

a guest
May 20th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <?php
  2. $host="localhost"; // Host name
  3. $username="root"; // Mysql username
  4. $password=""; // Mysql password
  5. $db_name="slate"; // Database name
  6. $tbl_name="posts"; // Table name
  7. echo "TEST Username or Password";
  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. $class=$_POST['class'];
  13.  
  14.  
  15. $sql="SELECT post FROM $tbl_name WHERE class='$class'";
  16. $result=mysql_query($sql);
  17.  
  18. // Mysql_num_row is counting table row
  19. $count=mysql_num_rows($result);
  20. // If result matched $myusername and $mypassword, table row must be 1 row
  21.  
  22. while($row = mysql_fetch_array($result))
  23. {
  24. echo "<div>";
  25. echo $row['post'];
  26. echo "<br />";
  27. echo "</div>";
  28. }
  29.  
  30. mysql_close($con);
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement