'; print ''; print "Form to Control a Database"; print "
"; print "Please choose an action from the following:
"; print ''; print ''; print '

'; print '
W3C Button to test XHTML validation
'); print (''); } elseif ($_POST['LAST'] == "MAIN"){ // if ( $_POST[command] == "VIEWBIDS"){ // viewbids(); // } if ( $_POST['command'] == "VIEWAUCTIONS"){ viewauctions(); } //if ( $_POST[command] == "PLACEBID"){ // placebid(); // } if ( $_POST['command'] == "ADDITEM"){ additem(); } if ( $_POST['command'] == "INSERTITEM"){ print "Change this to call the insertitem() function from addauction_insert.php"; } /* if ( $_POST['command'] == "ADDUSER"){ adduser(); } */ } /*CUT THE FOLLOWING lines and use the mydb3.php class instead NOTE DO NOT DO THIS UNTIL YOU HAVE FOLLOWED THE APPROPRIATE INSTRUCTIONS inside instructions.txt*/ function showerror() { if (mysqli_connect_error()){ die ("Error". mysqli_connect_errno() . " : " . mysqli_connect_error()); }else{ die ("Could not connect to the MySQL Database"); } } function connectdb($dbname) { include '../blurg.inc'; if (!($dbh = mysqli_connect("localhost", "coperni","$password" ))){ showerror(); } if(!mysqli_select_db($dbh, $dbname)){ showerror(); } return $dbh; } /*STOP CUTTING HERE!!! */ /*this function should be put into a file called viewauctions.php*/ function viewauctions() { $databasename = "m_coperni"; $db1 = connectdb($databasename); $QUERY1 = mysqli_prepare($db1, "SELECT i.item_id, i.item, i.category, i.starttime,i.endtime, c.firstname,c.lastname FROM auction_items i, customers c WHERE i.customer_id=c.customer_id ORDER BY i.item_id"); //Note, if you had things to bind, THIS is the line to do it! if(!mysqli_stmt_execute($QUERY1)){ showerror(); } else{ mysqli_stmt_store_result($QUERY1); mysqli_stmt_bind_result($QUERY1, $item_id, $item, $category, $starttime, $endtime,$firstname, $lastname); print<< Test of Auction_Items Database STARTHTML; $bgcolor="#00FF00"; while(mysqli_stmt_fetch($QUERY1)){ print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; if ( $bgcolor == "#00FF00"){ $bgcolor = "#00FFFF"; } else { $bgcolor = "#00FF00"; } } print "
Item ID Customer Name Item Name Category Auction Start Auction End
" .$item_id ."" .$firstname ." ". $lastname ."" .$item ."" .$category ."" .$starttime ."" .$endtime ."
"; } mysqli_close($db1); print '
W3C Button to test XHTML validation
'; print ('Go Back to Main DB Control Page'); print ''; } /*This function should be put into a file called additem.php */ function additem() { print<< STARTHTML; print ('
'); print ('Please enter the name of your item'); print ('
'); print 'Please Select your name from the following:'; //Note: need a seperate form to add yourself as a customer $databasename = "m_coperni"; $db2 = connectdb($databasename); $QUERY2 = mysqli_prepare($db2,'select customer_id, firstname, lastname from customers'); //NOTE: Binding parameters would occur here if you had them if(!mysqli_stmt_execute($QUERY2)){ showerror(); } else{ mysqli_stmt_store_result($QUERY2); mysqli_stmt_bind_result($QUERY2, $customer_id, $firstname, $lastname); print '
\n"; } $QUERY3 = 'show columns from auction_items like \'category\''; if(!($query3result = mysqli_query($db2, $QUERY3))){ showerror(); mysqli_close($db2); } else{ print '"; } print "
\n"; print ""; print "
\n"; print "Enter Minimum Starting Bid:"; print '
'; print (''); print (''); print (''); print ('
'); print ''; print ''; } ?>