'; 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'] == "ADDUSER"){ adduser(); } */ } elseif ($_POST['LAST'] == "UPDATEITEM"){ print "This part is not done yet"; } 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; } function viewauctions() { $databasename = "m_coperni"; $db1 = connectdb($databasename); $QUERY1 = "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"; if(!($query1result = mysqli_query($db1, $QUERY1))){ showerror(); } else{ print<< Test of Auction_Items Database STARTHTML; $bgcolor="#00FF00"; while($row = mysqli_fetch_assoc($query1result)){ 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
" .$row["item_id"] ."" .$row["firstname"] ." ". $row["lastname"]."" .$row["item"] ."" .$row["category"] ."" .$row["starttime"] ."" .$row["endtime"] ."
"; } mysqli_close($db1); print '
W3C Button to test XHTML validation
'; print ('Go Back to Main DB Control Page'); print ''; } 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 = 'select customer_id, firstname, lastname from customers'; if(!($query2result = mysqli_query($db2, $QUERY2))){ showerror(); } else{ print '
\n"; } $QUERY3 = 'show columns from auction_items like \'category\''; if(!($query3result = mysqli_query($db2, $QUERY3))){ showerror(); mysqli_close($db2); } else{ print '"; } print "

Short Item Name: "; print "
\n"; print ""; print "
\n"; print "Enter Minimum Starting Bid:"; print '
'; print (''); print (''); print ('

'); print ''; print ''; } ?>