Unformatted text preview:

04/02/1007:58:15 1florist-c.php<?phpecho "DEBUG: Program started.<BR />";// Connect to the database.$db_server = mysql_connect("orion.csl.mtu.edu", "nilufer", "nilufer");// Check the result of the connection.if ($db_server) echo "DEBUG: Connected to database successfully.<BR />";else die ("Unable to connect to MySQL: " . mysql_error());// Select the database to work with. mysql_select_db("nilufer", $db_server) or die("Unable to select database: " . mysql_error());// Issue a query to the database: retrieve all the records (rows).// This is the string form of the query as you would type it to mysql.$query = "SELECT * FROM florists";// Submit the query and get the result.$result = mysql_query ($query);// Check if the command executed successfully.if (!$result) die ("Database access failed:" . mysql_error());// Get the number of rows (records).$rows = mysql_num_rows($result);// Print the number of rows.echo "DEBUG: There are " . $rows . " records in the database.<BR />";04/02/1007:58:15 2florist-c.php// ----------- NEW -----------// Print each record in a loop.// Each field in a record can be accessed as an array.for ($j = 0 ; $j < $rows ; ++$j){ $row = mysql_fetch_row($result); echo <<<_END<pre> ID $row[0] Name $row[1] Address $row[2] City $row[3] Zipcode $row[4] Phone $row[5] Starting price $row[6]</pre>_END;}// ----------- END -----------// Close the connection. mysql_close($db_server);// This is a function for later (forms).function get_post($var){ return


View Full Document

MTU SSE 3200 - LECTURE NOTES

Download LECTURE NOTES
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LECTURE NOTES and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LECTURE NOTES 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?