PHP MYSQL CONNECT


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. $user="";
  3. $password="";
  4. $database="";
  5. mysql_connect(localhost,$user,$password);
  6.  
  7. @mysql_select_db($database) or die( "Unable to select database");
  8.  
  9. $query="SELECT * FROM law_projects";
  10. $result=mysql_query($query);
  11.  
  12. $num=mysql_numrows($result);
  13.  
  14.  
  15.  
  16. echo "<b><center>Database Output</center></b><br><br>";
  17.  
  18. $i=0;
  19. while ($i < $num) {
  20.  
  21. $city=mysql_result($result,$i,"city");
  22.  
  23. echo "<b>$city</b><br>";
  24.  
  25. $i++;
  26. }
  27.  
  28. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.