I am haveing trouble with updating a row out of a table. If there is one row in the table the edit works ok. But if I have more then 1 row in the table it will only let me edit the last row can any body help on this. Below is the SQL part

]

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
  $updateSQL = sprintf("UPDATE CellLoad_Prep SET Date_Start=%s, Version=%s, Comments=%s, CST=%s, Loaded_by=%s, Work_Sheet_Created_by=%s, Work_Sheet_Sent_by=%s, Put_on_Schedule=%s, Monday=%s, Tuesday=%s, Wednesday=%s, Thursday=%s, Friday=%s, Saturday=%s, Sunday=%s, ECP_REL=%s, EVDO_REL=%s, Change_Control_created=%s WHERE Prep_ID=%s",
                       GetSQLValueString($_POST['Date_Start'], "text"),
                       GetSQLValueString($_POST['Version2'], "text"),
                       GetSQLValueString($_POST['Comments2'], "text"),
                       GetSQLValueString($_POST['CST'], "text"),
                       GetSQLValueString($_POST['Loaded_by'], "text"),
                       GetSQLValueString($_POST['Work_Sheet_Created_by'], "text"),
                       GetSQLValueString($_POST['Work_Sheet_Sent_by'], "text"),
                       GetSQLValueString(isset($_POST['Put_on_Schedule']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($_POST['Monday']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($_POST['Tuesday']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($_POST['Wednesday']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($_POST['Thursday']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($_POST['Friday']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($_POST['Saturday']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($_POST['Sunday']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString($_POST['ECP_REL'], "text"),
                       GetSQLValueString($_POST['EVDO_REL'], "text"),
                       GetSQLValueString($_POST['Change_Control_created'], "text"),
                       GetSQLValueString($_POST['Prep_ID'], "int"));
 mysql_select_db($database_TechSupport, $TechSupport);
  $Result1 = mysql_query($updateSQL, $TechSupport) or die(mysql_error());
mysql_select_db($database_TechSupport, $TechSupport);
$query_getCellprep = "SELECT * FROM CellLoad_Prep WHERE CellLoad_Prep.Put_on_Schedule LIKE 'N' OR CellLoad_Prep.Put_on_Schedule IS NULL";
$getCellprep = mysql_query($query_getCellprep, $TechSupport) or die(mysql_error());
$row_getCellprep = mysql_fetch_array($getCellprep);
$totalRows_getCellprep = mysql_num_rows($getCellprep);

This is the HTML/PHP Part

<input name="hiddenField2" type="hidden" id="hiddenField2" value="N" />
    <input type="hidden" name="MM_insert" value="form1" />
  </form>
  <p>&nbsp;</p>
  <form action="<?php echo $editFormAction; ?>" id="form2" name="form2" method="POST">
    <table width="200" border="1">
      <tr align="center">
        <td nowrap="nowrap">ID</td>
        <td nowrap="nowrap">Switch</td>
        <td nowrap="nowrap">Date Start</td>
        <td nowrap="nowrap">Version</td>
        <td nowrap="nowrap">Comments</td>
        <td nowrap="nowrap">Centeral Start Time</td>
        <td nowrap="nowrap">Worksheet Created</td>
        <td nowrap="nowrap">ECP REL</td>
        <td nowrap="nowrap">EVDO REL</td>
        <td nowrap="nowrap">Change Control </td>
        <td nowrap="nowrap">Work Sheet Sent</td>
        <td nowrap="nowrap">Software Loaded by</td>
        <td nowrap="nowrap">Day of the Week</td>
        <td nowrap="nowrap">Edit Button</td>
        <td nowrap="nowrap">Put on Schedule</td>
      </tr>
      <?php do { ?>
        <tr align="center">
          <td><label>
            <input type="hidden" name="Prep_ID" value="<?php echo $row_getCellprep['Prep_ID']; ?>"/>
            <?php echo $row_getCellprep['Prep_ID']; ?>
          </label></td>
          <td><label>
            <?php echo $row_getCellprep['Switch']; ?>
          </label></td>
          <td><label>
            <input name="Date_Start" type="text" id="Date_Start" value="<?php echo $row_getCellprep['Date_Start']; ?>" />
          </label></td>
          <td><label>
            <input name="Version2" type="text" id="Version2" value="<?php echo $row_getCellprep['Version']; ?>" />
          </label></td>
          <td><label>
            <input name="Comments2" type="text" id="Comments2" value="<?php echo $row_getCellprep['Comments']; ?>" />
          </label></td>
          <td><label>
            <input name="CST" type="text" id="CST" value="<?php echo $row_getCellprep['CST']; ?>" />
          </label></td>
          <td><label>
            <input name="Work_Sheet_Created_by" type="text" id="Work_Sheet_Created_by" value="<?php echo $row_getCellprep['Work_Sheet_Created_by']; ?>" />
          </label></td>
          <td><label>
            <input name="ECP_REL" type="text" id="ECP_REL" value="<?php echo $row_getCellprep['ECP_REL']; ?>" />
          </label></td>
          <td><label>
            <input name="EVDO_REL" type="text" id="EVDO_REL" value="<?php echo $row_getCellprep['EVDO_REL']; ?>" />
          </label></td>
          <td><label>
            <input name="Change_Control_created" type="text" id="Change_Control_created" value="<?php echo $row_getCellprep['Change_Control_created']; ?>" />
          </label></td>
          <td><label>
            <input name="Work_Sheet_Sent_by" type="text" id="Work_Sheet_Sent_by" value="<?php echo $row_getCellprep['Work_Sheet_Sent_by']; ?>" />
          </label></td>
          <td><label>
            <input name="Loaded_by" type="text" id="Loaded_by" value="<?php echo $row_getCellprep['Loaded_by']; ?>" />
          </label></td>
          <td nowrap="nowrap"><label>
<input <?php if (!(strcmp($row_getCellprep['Monday'],"Y"))) {echo "checked=\"checked\"";} ?> name="Monday" type="checkbox" id="Monday" value="N" />            
Mon</label>
            <label>
            <input <?php if (!(strcmp($row_getCellprep['Tuesday'],"Y"))) {echo "checked=\"checked\"";} ?> name="Tuesday" type="checkbox" id="Tuesday" value="Y" />
            Tue</label>
            <label>
            <input <?php if (!(strcmp($row_getCellprep['Wednesday'],"Y"))) {echo "checked=\"checked\"";} ?> name="Wednesday" type="checkbox" id="Wednesday" value="Y" />
            Wed</label>
            <label>
            <input <?php if (!(strcmp($row_getCellprep['Thursday'],"Y"))) {echo "checked=\"checked\"";} ?> name="Thursday" type="checkbox" id="Thursday" value="Y" />
            Thur</label>
            <label>
            <input <?php if (!(strcmp($row_getCellprep['Friday'],"Y"))) {echo "checked=\"checked\"";} ?> name="Friday" type="checkbox" id="Friday" value="Y" />
            Fri</label>
            <label>
            <input <?php if (!(strcmp($row_getCellprep['Saturday'],"Y"))) {echo "checked=\"checked\"";} ?> name="Saturday" type="checkbox" id="Saturday" value="Y" />
            Sat</label>
            <label>
            <input <?php if (!(strcmp($row_getCellprep['Sunday'],"Y"))) {echo "checked=\"checked\"";} ?> name="Sunday" type="checkbox" id="Sunday" value="Y" />
          Sun</label></td>
          <td><label>
            <input type="submit" name="button2" id="button2" value="Submit" />
          </label></td>
          <td><label>
            <input name="Put_on_Schedule" type="checkbox" id="Put_on_Schedule" value="y" />
          </label></td>
        </tr>
        <?php } while ($row_getCellprep = mysql_fetch_assoc($getCellprep)); ?>
    </table>
      <input type="hidden" name="MM_update" value="form2" />
  </form>

have you tried assigning variables to each $_POST its easier to track also
GetSQLValueString($_POST, "int")); //why do you have 2 )) and one (???
I would approach it like this

$pid = ($_POST['Prep_ID']);
 
in the update 

where Prep_ID='$pid'

also i think you need to put the update after you are getting your variables not before

This article has been dead for over six months. Start a new discussion instead.