Advertisement
touhid_xml

PHP SQL BASIC

Sep 2nd, 2015
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.  
  4.  
  5. $con = mysql_connect("localhost","root","");
  6.  
  7. if(!$con){
  8.   die("Unable connect to mysql server");
  9. }
  10.  
  11. mysql_select_db("test",$con);
  12.  
  13. //$sql = "CREATE TABLE employee(name varchar(255),age int(11),salary DOUBLE);";
  14. //$sql = "INSERT INTO employee (name,age,salary) VALUES('Touhid',25,10000.50)";
  15.  
  16. $sql = "SELECT * FROM employee";
  17. $query = mysql_query($sql,$con);
  18. echo "<table border=\"1\">";
  19. while($row = mysql_fetch_array($query)){
  20.  echo "<tr><td>{$row['name']}</td><td>{$row['age']}</td><td>{$row['salary']}</td></tr>\n";
  21. }
  22. echo "</table>";
  23.  
  24. if(!$query){
  25.     echo mysql_error();
  26. }else{
  27. echo "Query Successful";
  28. }
  29.  
  30. mysql_close($con);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement