fehrenbacher33 Posted December 12, 2009 Share Posted December 12, 2009 I cant get this to update the records into the database <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Instrctional Support Service</title> <meta name="keywords" content="" /> <meta name="description" content="" /> <link href="styles.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .style2 { font-size: large } .style3 { font-size: x-large; color: #AA0000; } --> </style> </head> <body> <div id="content"> <!-- header begins --> <div id="header"> <div id="menu"> <ul> <li class="first"><a href="../ISSO HOME/index.html" title="" target="_blank">Home</a></li> <li></li> <li><a href="https://mycourses.siu.edu/webct/entryPageIns.dowebct" title="" target="_blank">WebCT</a></li> <li><a href="http://siuc.edu/" title="" target="_blank">SIU</a></li> <li><a href="http://www.lib.siu.edu/index.html" title="" target="_blank">Library</a></li> <li><a href="#" title="">Contact</a></li> <li><a href="#" title="">710</a></li> <li><a href="http://www.infotech.siuc.edu/" title="" target="_blank">IT Dept</a></li> <li> <div align="center"><img src="images/pic11.png" alt="Pic4" width="202" height="98" /></a></div> </li> </ul> </div> <div id="logo"></div> </div> <!-- header ends --> <!-- content begins --> <div id="right"> <h2 align="center">Recipt Printout Form<br /> </h2> </div> <div id = "form"> <form action = "recipt.php" id = "equipmentForm" method = "post" > <br/> <br/> <br/> <table width="629" border="1" align="center" cellpadding="3" cellspacing="3" > <tr> <td>Order Number: </td> <td><input type="text" name = "OID" id = "OID" size="20" maxlength="20" /></td> </tr> <tr> <td>Dawg Tag: </td> <td><input type="text" name = "SID" id = "SID" size="20" maxlength="20" /></td> </tr> <tr> <td colspan="2"><input type ="reset" name = "Reset" id = "Reset" /> <input type = "submit" name = "Submit" id= "Submit" value="Submit"/> </td> </tr> </table> </form> </div> </div> <br/> <!--content ends --> <!-- // // From Metamorphosis Design team: // We request you retain the full copyright notice below including the link to www.metamorphozis.com. This not only gives respect to the large amount of time given freely by the developers but also helps build interest, traffic and use of our free and paid designs. If you cannot (for good reason) retain the full copyright we request you at least leave in place the Website Templates line, with Website Templates linked to www.metamorphozis.com. If you refuse to include even this then support may be affected. You are allowed to use this design only if you agree to the following conditions: - You cannot remove copyright notice from this design without our permission. - You cannot use images from this design anywhere else without permission. - If you modify this design it still should contain copyright because it is based on our work. For support visit http://www.metamorphozis.com/contact/index_contact2.php The Metamorphosis Design : 2007 // --> <!--footer begins --> </div> <!-- footer ends--> </body> </html> <?php $OID =$_POST['OID']; $SID = $_POST['SID']; $server = "localhost"; // server name $user = "root"; // user name $pwd = ""; // password $connect = mysql_connect($server, $user, $pwd) or die ("Error connection failed!"); $sel = mysql_select_db("SIU"); if(!$sel) exit("Error: Could not select database!"); $sql = " SELECT * FROM Equipment_Receipt, Equipment WHERE $OID = Equipment_Receipt.Order_ID AND $SID = Equipment_Receipt.Dwag_Tag"; $query = mysql_query($sql); if (mysql_num_rows($query) == 0) { echo "<h3>No records found</h3>"; } else { $row = mysql_fetch_array($query); $Category = $row['Equipment_Category']; $Pickup = $row['Pickup']; $Buliding = $row['Buliding']; $SIU_STATUS = $row['SIU_STATUS']; $Dept = $row['Dept']; $Phone = $row['Phone']; $Comments = $row['Comments']; $OID = $row['Order_ID']; $SID = $row['Dwag_Tag']; $Name = $row['Name']; $EID = $row['Equip_Number']; } echo " <h1>Update Equipment Order</h1> <hr> <form action='update_receipt.php' method='POST'> <table align='center'> <tr> <td>Name:</td> <td><input type='text' name='Name' value='$Name' readonly></td> </tr> <tr> <td>Order ID:</td> <td><input type='text' name='OID' value='$OID' readonly></td> </tr> <tr> <td>Dawg Tag:</td> <td><input type='text' name='DawgTag' value='$SID' readonly></td> </tr> <tr> <td>Equipment ID:</td> <td><input type='text' name='EID' value='$EID' readonly></td> </tr> <tr> <td>Buliding:</td> <td><input type='text' name='Buliding' value=' $Buliding' readonly></td> </tr> <tr> <td>SIU STATUS:</td> <td><input type='radio' name='STATUS' value='Student' "; echo($SIU_STATUS =='Student') ? 'checked' : ''; echo ">Student <input type='radio' name='STATUS' value='Staff' "; echo($SIU_STATUS=='Staff') ? 'checked' : ''; echo ">Staff <input type='radio' name='STATUS' value='Professor' "; echo($SIU_STATUS=='Professor') ? 'checked' : ''; echo ">Professor </td> </tr> <tr> <td>Department:</td> <td><input type='text' name='Dept' value='$Dept'></td> </tr> <tr> <td>Phone:</td> <td><input type='text' name='Phone' value='$Phone'></td> </tr> <br /> <br /> <br/> <tr> <td>Message:</td> <td><textarea name='Comments' rows= '3' cols ='30'> '$Comments' </textarea> </td> </tr> <tr> <td> Orderd Equipment :</td> <td>"; $sql = "select Equipment.Equip_Number, Equipment.Equipment_Name ,Equipment.Equipment_Category, Equipment_receipt.Order_ID from Equipment right join Equipment_receipt ON Equipment.Equip_Number = Equipment_receipt.Equip_Number WHERE $OID = equipment_receipt.order_id order by Equipment_Category"; $query = mysql_query($sql); if(!mysql_num_rows($query)) { echo '<h3>No records found</h3>'; } else { echo "<select name='ECategory[]' size='5' multiple style='width:300px;'>"; while($row = mysql_fetch_array($query)) { $Equip_Number = $row['Equip_Number']; $Category = $row['Equipment_Category'] . ' - ' . $row['Equipment_Name']; echo "<option value=Equip_Number "; echo ($row['Order_ID'] != null) ? "selected" : ""; echo ">$Category</option>"; } echo '</select>'; } echo " </td> </tr> <tr> <td> Pickup Date:</td> <td><input type='text' name='Pickup' value='$Pickup' ></td> </tr> <tr> <td colspan=2 align='center'> <input type=submit name=submit value='Update Student'> <input type=reset name=reset value=Clear> </td> </tr> </table> </form> "; mysql_close($connect); ?> <?php $OID = $_POST['OID']; $SID = $_POST['SID']; $Buliding = $_POST['Buliding']; $Dept = $_POST['Dept']; $Pickup = date('Y-m-d',strtotime($_POST ['Pickup'])); $Comments = $_POST['Comments']; $Phone = $_POST['Phone']; $EID = $_POST['EID']; if(!isset($_POST['STATUS'])) $STATUS = 'off'; else $STATUS = $_POST['STATUS']; $server="localhost"; // Server name $uid ="root"; // User name $pass=""; // Password $connect = mysql_connect("$server","$uid","$pass") or die("ERROR: Selecting SERVER failed"); $sel = mysql_select_db("SIU"); if(!$ser) exit("Error: Could not select database"); $sql = "UPDATE Equipment_Receipt SET Pickup = '$Pickup', Buliding = '$Buliding', Dept= '$Dept', Comments = '$Comments', Phone = '$Phone', STATUS = '$STATUS' WHERE $OID = $OID AND $EID = $EID "; echo $sql; $query = mysql_query($sql); $numRows = mysql_affected_rows(); if($numRows == 1) { echo "<h3>Order has been Updated"; } mysql_close($connect); ?> Link to comment https://forums.phpfreaks.com/topic/184854-update-help/ Share on other sites More sharing options...
vinpkl Posted December 12, 2009 Share Posted December 12, 2009 use tags for posting information and code Link to comment https://forums.phpfreaks.com/topic/184854-update-help/#findComment-975790 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.