topical media & game development

talk show tell print

server-php-sql-example-page.php / php

  <h4>page -- 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());  
  // Print out the contents of the entry 
  echo "<table border='1'>";
  echo "<tr> <th>Name</th> <th>Age</th> </tr>";
  // keeps getting the next row until there are no more to get
  while(row = mysql_fetch_array( result )) {
          // Print out the contents of each row into a table
          echo "<tr><td>"; 
          echo row['name'];
          echo "</td><td>"; 
          echo row['age'];
          echo "</td></tr>"; 
  echo "</table>";

(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.