topical media & game development

talk show tell print

server-php-sql-example-query.php / php

  <h4>query -- php/mysql</h4>
  mysql_connect("localhost", "root", "hush") or die(mysql_error());
  mysql_select_db("local") or die(mysql_error());
  // Retrieve all the data from the "example" table
  result = mysql_query("SELECT * FROM example")
  or die(mysql_error());  
  // store the record of the "example" table into row
  row = mysql_fetch_array( result );
  // Print out the contents of the entry 
  echo "Name: ".row['name']."  ";
  echo " Age: ".row['age']."<br />";
  <h4>In a loop remainder(s)</h4>
  while(row = mysql_fetch_array(result)){
          echo row['name']. " - ". row['age'];
          echo "<br />";

(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.