Guest User

Untitled

a guest
Oct 24th, 2018
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. <?php
  2. $dbhost = 'localhost:3036';
  3. $dbuser = 'root';
  4. $dbpass = 'rootpassword';
  5.  
  6. $conn = mysql_connect($dbhost, $dbuser, $dbpass);
  7.  
  8. if(! $conn ) {
  9. die('Could not connect: ' . mysql_error());
  10. }
  11.  
  12. $sql = 'SELECT emp_id, emp_name, emp_salary FROM employee';
  13. mysql_select_db('test_db');
  14. $retval = mysql_query( $sql, $conn );
  15.  
  16. if(! $retval ) {
  17. die('Could not get data: ' . mysql_error());
  18. }
  19.  
  20. while($row = mysql_fetch_assoc($retval)) {
  21. echo "EMP ID :{$row['emp_id']} <br> ".
  22. "EMP NAME : {$row['emp_name']} <br> ".
  23. "EMP SALARY : {$row['emp_salary']} <br> ".
  24. "--------------------------------<br>";
  25. }
  26.  
  27. echo "Fetched data successfully\n";
  28.  
  29. mysql_close($conn);
  30. ?>
Add Comment
Please, Sign In to add comment