04/02/1007:58:43 1florist-d.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:43 2florist-d.php// ----------- NEW -----------//// The four lines below the </pre> are new.// We have a new button to delete the record from the database.// It is not functional yet.//// ----------- END -----------// 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><form action="florist-d.php" method="post"><input type="hidden" name="hdelete" value="yes" /><input type="hidden" name="hid" value="$row[0]" /><input type="submit" value = "Delete record" /> </form>_END;}// Close the connection. mysql_close($db_server);// This is a function for later (forms).function get_post($var){ return
View Full Document