Hey all, I am trying to update submissions from my SQL database from an edit page via an edit link in line with the submission which captures the ID of the database entry. When I click the edit link a new page opens and it has a form to update information not captured previously. This page is not pulling all the previously submitted data - not sure if it can actually do that or not, also (I don't know if I need to ONLY select the fields that are to be added after original submission or all fields of the database table) I am really new to this whole thing and have been trying to follow examples and tutorials and have had no luck with the update portion. So anyway here is my edit page code:

<?php
$con=mysqli_connect("server.com","username","password");
mysqli_select_db($con, 'databasename');
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  $query = "SELECT orderNumber, customerName, salesRep, DatePicker, shipMethod, trackingNumber, StatusCheck, Price FROM table_name WHERE id = '$ID'";

$result = @mysqli_query($query);
while($row = mysqli_fetch_object($result))
mysqli_fetch_object($result);
?>
<form name="update order" method="post" action="edit.php?a=edit&id=<? echo($ID) ?>&update=1">
  <table width="50%" border="0" cellspacing="0" cellpadding="0">
    <tr> 
      <td width="50%">Order Number</td>
      <td><input name="orderNumber" type="text" id="orderNumber" value="<? echo($row->orderNumber) ?>"></td>
    </tr>
     <tr> 
      <td>Price</td>
      <td><input name="Price" type="text" id="Price" value="<? echo($row->Price) ?>"></td>
    </tr>
    <tr> 
      <td>Customer Name</td>
      <td><input name="customerName" type="text" id="customerName" value="<? echo($row->customerName) ?>"></td>
    </tr>
    <tr> 
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr> 
      <td>Sales Rep</td>
      <td><input name="salesRep" type="text" id="salesRep" value="<? echo($row->salesRep) ?>"></td>
         <tr> 
      <td>Must Ship By</td>
      <td><input name="DatePicker" type="text" id="DatePicker" value="<? echo($row->DatePicker) ?>"></td>
         <tr> 
      <td>Shipping Method</td>
      <td><input name="shipMethod" type="text" id="shipMethod" value="<? echo($row->shipMethod) ?>"></td>
         <tr> 
      <td>Tracking Number</td>
      <td><input name="trackingNumber" type="text" id="trackingNumber" value="<? echo($row->trackingNumber) ?>"></td>
    </tr>
    <tr> 
      <td>Status</td>
      <td><input name="Statuscheck" type="radio" name="Statuscheck" value="PROCESSING"> PROCESSING<br><input name="Statuscheck" type="radio" name="Statuscheck" value="PICKED"> PICKED<br><input name="Statuscheck" type="radio" name="Statuscheck" value="SHIPPED">  SHIPPED<br><value="<? echo($row->Statuscheck) ?>"></td>
    </tr>
    <tr> 
      <td colspan="2"><div align="center">
          <input name="hiddenField" type="hidden" value="update">
          <input name="add" type="submit" id="add" value="Update">
        </div></td>
    </tr>
  </table>
  </form>

<?php
$query = "UPDATE Orders SET orderNumber= '$orderNumber, customerName= '$customerName', DatePicker= '$DatePicker', shipMethod= '$shipMethod', trackingNumber= '$trackingNumber', Statuscheck= '$Statuscheck', Price= '$Price' timestamp = NOW() WHERE id = '$ID'";
$result = @mysqli_query($query);

?>

Also, the form action URL, I'm not sure how exactly that works with the ?id=update=1 after the .php. Please forgive my stupidness and being a noob to all this. Thank you very much in advance for your help!

you will need to process the form before you can initiate the update..

for example,

if(isset($_GET['a']) && (isset($_GET['id']))){
$ID = $_GET['id'];

    ## process the form
    if(isset($_POST['hiddenField'])){

    ## do the query here from

    }


    }

Make sure to sanitized your form data....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.