Jump to content


Photo

Update database in repeating region?


  • Please log in to reply
2 replies to this topic

#1 mum4d

mum4d
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 28 April 2006 - 11:52 AM

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:
$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);

the code for my Update statement is:
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());
}

The code for my repeating table is:
<?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)); ?>


#2 Daniel.Conaghan1

Daniel.Conaghan1
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 28 April 2006 - 12:38 PM

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=auto:0]

$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=auto:0]

Is this too simplistic?

#3 mum4d

mum4d
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 28 April 2006 - 01:07 PM

[!--quoteo(post=369559:date=Apr 28 2006, 01:38 PM:name=Lienad)--][div class=\'quotetop\']QUOTE(Lienad @ Apr 28 2006, 01:38 PM) View Post[/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=auto:0]

$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=auto:0]

Is this too simplistic?
[/quote]

This is FANTASTIC

Many Thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users