Jump to content

Multiple form update


amwd07

Recommended Posts

Please help someone  ???

I am having trouble being able to update multiple records using checkboxes

 

<form method="POST" action="<?php echo $editFormAction; ?>" name="ratings">
<table border="1" align="center" cellpadding="8" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#F4F4F4">
  <tr>
    <td bgcolor="#FFEEAA"><strong>name
        <input name="rating_id" type="hidden" id="rating_id" value="<?php echo $row_rsRatings['rating_id']; ?>" />
    </strong></td>
    <td bgcolor="#FFEEAA"><strong>email</strong></td>
    <td bgcolor="#FFEEAA"><strong>postcode</strong></td>
    <td bgcolor="#FFEEAA"><strong>ratings</strong></td>
    <td bgcolor="#FFEEAA"><strong>created</strong></td>
    <td bgcolor="#FFEEAA"><div align="center"><strong>onhold</strong></div></td>
    <td bgcolor="#FFEEAA"> </td>
  </tr>
<?php 
do { 
$rateid = $row_rsRatings['rating_id'];
$rateposted = $_POST['onhold'.$rateid];
print_r($rateposted);

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "ratings")) {
  $updateSQL = sprintf("UPDATE restaurant_ratings SET onhold=%s WHERE rating_id=%s",
                       GetSQLValueString(isset($rateposted) ? "true" : "", "defined","1","0"),
                       GetSQLValueString($_POST['rating_id'], "int"));

  mysql_select_db($database_connDW, $connDW);
  $Result1 = mysql_query($updateSQL, $connDW) or die(mysql_error());
}
?>
    <tr>
      <td><strong><?php echo $row_rsRatings['name']; ?></strong></td>
      <td><?php echo $row_rsRatings['email']; ?></td>
      <td><?php echo $row_rsRatings['postcode']; ?></td>
      <td><?php echo $row_rsRatings['ratings']; ?></td>
      <td><?php echo $row_rsRatings['created']; ?></td>
      <td><div align="center">
        <input type="checkbox" name="onhold<?php echo $rateid ?>" id="onhold<?php echo $rateid ?>" value="1" <?php if (!(strcmp($row_rsRatings['onhold'],1))) {echo "checked=\"checked\"";} ?> />
        <?php echo $rateid ?></div></td>
      <td><input type="submit" name="rateupdate" id="rateupdate" value="Update" /></td>
    </tr>
    <?php } while ($row_rsRatings = mysql_fetch_assoc($rsRatings)); ?>

</table>
</form>

Link to comment
Share on other sites

I have changed my code so the $editforaction is not in the loop

and still can't work this one out all I want to do is update more than 1 record with each record having it's own update button ?

 

<form method="POST" action="<?php echo $editFormAction; ?>" name="ratings">
<table border="1" align="center" cellpadding="8" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#F4F4F4">
  <tr>
    <td bgcolor="#FFEEAA"><strong>name</strong></td>
    <td bgcolor="#FFEEAA"><strong>email</strong></td>
    <td bgcolor="#FFEEAA"><strong>postcode</strong></td>
    <td bgcolor="#FFEEAA"><strong>ratings</strong></td>
    <td bgcolor="#FFEEAA"><strong>created</strong></td>
    <td bgcolor="#FFEEAA"><div align="center"><strong>onhold</strong></div></td>
    <td bgcolor="#FFEEAA"> </td>
  </tr>

<?php 
do { 
$rateid = $row_rsRatings['rating_id'];
$rateposted = $_POST['onhold'.$rateid];
print_r($rateposted);
?>
  <tr>
  <td><strong><?php echo $row_rsRatings['name']; ?></strong></td>
      <td><?php echo $row_rsRatings['email']; ?></td>
      <td><?php echo $row_rsRatings['postcode']; ?></td>
      <td><?php echo $row_rsRatings['ratings']; ?></td>
      <td><?php echo $row_rsRatings['created']; ?></td>
      <td>
<div align="center">
<input name="rating_id" type="hidden" id="rating_id" value="<?php echo $rateid ?>" />   
<input type="checkbox" name="onhold<?php echo $rateid ?>" id="onhold<?php echo $rateid ?>" value="1" <?php if (!(strcmp($row_rsRatings['onhold'],1))) {echo "checked=\"checked\"";} ?> />
<?php echo $rateid ?></div></td>
<td><input type="submit" name="rateupdate" id="rateupdate" value="Update" /></td>
</tr>
<?php } while ($row_rsRatings = mysql_fetch_assoc($rsRatings)); ?>
</table>
</form>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.