home *** CD-ROM | disk | FTP | other *** search
/ Neil's C++ Stuff / 2002-11-php_neilstuff_com.zip / sql.php < prev    next >
Text File  |  2001-11-27  |  769b  |  31 lines

  1. <HTML>
  2. <HTML>
  3. <?php
  4. // Connecting, selecting database
  5. $link = mysql_connect("localhost:3306", "web", "b84ufishy")
  6.     or die("Could not connect");
  7. print "Connected successfully";
  8. mysql_select_db("bliss")
  9.     or die("Could not select database");
  10.  
  11. // Performing SQL query
  12. $query = "SELECT * FROM smpcntr";
  13. $result = mysql_query($query)
  14.     or die("Query failed");
  15.  
  16. // Printing results in HTML
  17. print "<table 
  18. border=1><TR><TD><B>id</B></TD><TD><B>page</B></TD><TD><B>referer</B></TD><TD><B>browser</B></TD></TR>\n";
  19. while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
  20.     print "\t<tr>\n";
  21.     foreach ($line as $col_value) {
  22.         print "\t\t<td>$col_value</td>\n";
  23.     }
  24.     print "\t</tr>\n";
  25. }
  26. print "</table>\n";
  27.  
  28. // Closing connection
  29. mysql_close($link);
  30. ?>
  31.