SQL Demo

This example is taken from the PHP online documentation at http://php.net

'; mysql_select_db('mheadway') or die('Could not select database'); // do we have to add a new entry if (strlen($last . $first . $phone)>0) { $iquery = "INSERT INTO addressbook ( last , first , phone ) " . " VALUES ('". $last . "', '" . $first . "', '" . $phone . "')"; echo "Submit query

\n $iquery \n
\n"; $result = mysql_query($iquery) or die('Insert failed: ' . mysql_error()); // Free resultset mysql_free_result($result); } // Performing SQL query switch($order) { case 'f': $query = 'SELECT * FROM addressbook order by first'; break; case 'p': $query = 'SELECT * FROM addressbook order by phone'; break; case 'l': default: $query = 'SELECT * FROM addressbook order by last'; break; } echo "

Query:

\n
 $query 
\n"; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); // Printing results in HTML echo "\n"; echo "\n"; foreach ($line as $col_value) { echo "\t\t\n"; } echo "\t\n"; } echo "
Last"; echo "First"; echo "Phone"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "\t
$col_value
\n"; // Free resultset mysql_free_result($result); // Closing connection mysql_close($link); ?>
Last Name
First Name
Phone Number