Re: Multiple Update from one form
| From: | Enda Nagle - Lists | Date: | Tue, 18 May 2004 22:56:40 +0000 |
| Subject: | Re: Multiple Update from one form | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-186504@lists.php.net to get a copy of this message | ||
Its OK guys,
Got something else myself.
Here¹s the solution... Any suggestions appreciated...
/////////////////////////////
// UPDATE PART
/////////////////////////////
$i=1;
//while ($ordersinfo[$i])
while ($i < $total)
{
$session = $ordersinfo[$i][session];
$tracking = $ordersinfo[$i][tracking];
$kb_ship = $ordersinfo[$i][kb_ship];
$update = mysql_query("UPDATE products_orders SET tracking='$tracking',
kb_ship='$kb_ship' WHERE session='$session'") or die (mysql_error());
$i++;
}
/////////////////////////////
// MAIN PART
/////////////////////////////
...
<td align=\"default\" width=\"100\"><input type=text
name=\"ordersinfo[$i][tracking]\" value=\"" . $roworders[tracking] .
"\"
size=25></td>
...
Regards
Enda
--
On 18/05/2004 23:20, "Enda Nagle - Lists" <lists@nightsol.net> wrote:
> Hi
>
> I have a current application where I am listing a table of order details,
> where a fulfillment company can enter the tracking number and the cost of
> the shipment.
>
> At present, I have up to 40 orders displayed, and when they click on the
> update¹ button, the code executes as
>
> if ((isset($tracking1)) && (isset($kb_ship1))){
> $update=mysql_query("UPDATE orders SET
> tracking='$tracking1',kb_ship='$kb_ship1' WHERE order_ref =
> '$ref1'",$link);
> }
>
> And this continues as tracking 2... tracking40.
>
> I would like to implement something like
>
> foreach ($_POST["ref"]){
> $update=mysql_query("UPDATE orders SET
> tracking='$tracking',kb_ship='$kb_ship' WHERE order_ref =
> '$ref'",$link);
> }
>
> Instead, but I¹m not so sure how I can do this, given that form variables
> cannot be named the same etc.
>
> I¹m sure that there¹s a better way that the way in which I¹m doing it at the
> moment, so any input would be appreciated.
>
> Thanks
>
> Enda
> --
>
>