Jump to content

Update database in repeating region?


mum4d

Recommended Posts

I have a page that displays info from a database in a "Repeating Region" table that is filtered by a MySql WHERE statement. I want to insert some extra data into the database only on the entry's displayed (filtered) leaving all other info in the database untouched. I can do this by creating an UPDATE form in the table and this gives me a "Submit" button in each row to update that row only.
OK Here's the problem....
I want to update all the filtered items with the same data in one coloum but leave all the other coloums as they were and threrefore I only want ONE SUBMIT BUTTON to update all entry's in one go.

It's like a shopping basket listing all the items a user has ordered, and when they press the confirm (Submit) button it add's a unique order number to their items.

Can this be Done??

The code for my SELECT statement is:
[code]$id4 = $_SESSION['kt_login_id'];
mysql_select_db($database_vistion, $vistion);
$query_basket = "SELECT * FROM vistion_basket WHERE id_copy ='$id4'";
$basket = mysql_query($query_basket, $vistion) or die(mysql_error());
$row_basket = mysql_fetch_assoc($basket);
$totalRows_basket = mysql_num_rows($basket);[/code]

the code for my Update statement is:
[code]if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
  $updateSQL = sprintf("UPDATE vistion_basket SET id_copy=%s, imagefile=%s, catagory=%s, code=%s, description=%s, basket_prodname=%s, quantity=%s, complete=%s, order_date=%s, location_code=%s, files_id=%s order_number=%s WHERE id_copy ='$id4'",
                       GetSQLValueString($_POST['id_copy'], "int"),
                       GetSQLValueString($_POST['imagefile'], "text"),
                       GetSQLValueString($_POST['catagory'], "text"),
                       GetSQLValueString($_POST['code'], "text"),
                       GetSQLValueString($_POST['description'], "text"),
                       GetSQLValueString($_POST['basket_prodname'], "text"),
                       GetSQLValueString($_POST['quantity'], "int"),
                       GetSQLValueString($_POST['complete'], "text"),
                       GetSQLValueString($_POST['order_date'], "text"),
                       GetSQLValueString($_POST['location_code'], "text"),
                       GetSQLValueString($_POST['files_id'], "int"),
                       GetSQLValueString($_POST['order_umber'], "int"),
                       GetSQLValueString($_POST['basket_id'], "int"));

  mysql_select_db($database_vistion, $vistion);
  $Result1 = mysql_query($updateSQL, $vistion) or die(mysql_error());
}[/code]

The code for my repeating table is:
[code]<?php do { ?>
        <table width="100%" height="20" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr bgcolor="<?php
if($SSAdv_m1%$SSAdv_change_every1==0 && $SSAdv_m1>0){
$SSAdv_k1++;
}
print $SSAdv_colors1[$SSAdv_k1%count($SSAdv_colors1)];
$SSAdv_m1++;
?>" valign="middle">
            <td><span class="style5">
              <form method="post" name="form2" action="<?php echo $editFormAction; ?>">
                    <table align="center">
                      <tr valign="baseline">
                        <td nowrap align="right">Basket_id:</td>
                        <td><?php echo $row_basket['basket_id']; ?></td>
                      </tr>
                      <tr valign="baseline">
                        <td nowrap align="right">Id_copy:</td>
                        <td><?php echo $row_basket['id_copy']; ?></td>
                      </tr>
                      <tr valign="baseline">
                        <td nowrap align="right">Imagefile:</td>
                        <td><?php echo $row_basket['imagefile']; ?></td>
                      </tr>
                      <tr valign="baseline">
                        <td nowrap align="right">Catagory:</td>
                        <td><?php echo $row_basket['catagory']; ?>></td>
                      </tr>
                      <tr valign="baseline">
                        <td nowrap align="right">Code:</td>
                        <td><?php echo $row_basket['code']; ?></td>
                      </tr>
                      <tr valign="baseline">
                        <td nowrap align="right">Description:</td>
                        <td><?php echo $row_basket['description']; ?></td>
                      </tr>
                      <tr valign="baseline">
                        <td nowrap align="right">Basket_prodname:</td>
                        <td><?php echo $row_basket['basket_prodname']; ?></td>
                      </tr>
                      <tr valign="baseline">
                        <td nowrap align="right">Quantity:</td>
                        <td><?php echo $row_basket['quantity']; ?></td>
                      </tr>
                      <tr valign="baseline">
                        <td nowrap align="right">Complete:</td>
                        <td><?php echo $row_basket['complete']; ?></td>
                      </tr>
                      <tr valign="baseline">
                        <td nowrap align="right">Order_date:</td>
                        <td><?php echo $row_basket['order_date']; ?></td>
                      </tr>
                      <tr valign="baseline">
                        <td nowrap align="right">Location_code:</td>
                        <td><?php echo $row_basket['location_code']; ?></td>
                      </tr>
                      <tr valign="baseline">
                        <td nowrap align="right">Files_id:</td>
                        <td><?php echo $row_basket['files_id']; ?></td>
                      </tr>
                      <tr valign="baseline">
                        <td nowrap align="right">Order Number </td>
                        <td><input type="text" name="order_number" value="<?php echo $num; ?>" size="32" /></td>
                      </tr>
                      <tr valign="baseline">
                        <td nowrap align="right"> </td>
                        <td><input type="submit" value="Update record"></td>
                      </tr>
                    </table>
                  <input type="hidden" name="MM_update" value="form2">
                    <input type="hidden" name="basket_id" value="<?php echo $row_basket['basket_id']; ?>">
                  </form>
                  <p> </p>
            </span></td>
            </tr>
        </table>
        <?php } while ($row_basket = mysql_fetch_assoc($basket)); ?>[/code]
Link to comment
Share on other sites

Yes, indeed it is very possible.

if we fiddle about with your select statement we can work it out....
When the user submits we run the script below.


[code]

$id4 = $_SESSION['kt_login_id'];
mysql_select_db($database_vistion, $vistion);
$update_basket = "UPDATE vistion_basket SET unique_number = $UN WHERE id_copy ='$id4'";
query($update_basket);

[code]

Is this too simplistic?
Link to comment
Share on other sites

[!--quoteo(post=369559:date=Apr 28 2006, 01:38 PM:name=Lienad)--][div class=\'quotetop\']QUOTE(Lienad @ Apr 28 2006, 01:38 PM) [snapback]369559[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Yes, indeed it is very possible.

if we fiddle about with your select statement we can work it out....
When the user submits we run the script below.
[code]

$id4 = $_SESSION['kt_login_id'];
mysql_select_db($database_vistion, $vistion);
$update_basket = "UPDATE vistion_basket SET unique_number = $UN WHERE id_copy ='$id4'";
query($update_basket);

[code]

Is this too simplistic?
[/quote]

This is FANTASTIC

Many Thanks
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.