Re: Updating multipile rows from an order history form ( ie same id)
From: Shane C (sclay_at_ceinternet.com.au)
Date: 02/12/04
- Next message: paulm844: "Repeat Region in Dreamweaver MX"
- Previous message: - Dazed: "mod_rewrite help requested, please"
- In reply to: Marcel: "Re: Updating multipile rows from an order history form ( ie same id)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 12 Feb 2004 14:48:23 -0800
"Marcel" <neegeenspam@hotentottententententoonstellingen.nl> wrote in message news:<402b4534$0$64875$7eb43735@news.versatel.net>...
> "Shane C" <sclay@ceinternet.com.au> schreef in bericht
> news:4e28e80.0402111720.8bd7aaa@posting.google.com...
> > "Marcel" <neegeenspam@hotentottententententoonstellingen.nl> wrote in
> message news:<4029e2ae$0$64878$7eb43735@news.versatel.net>...
> > > "Shane C" <sclay@ceinternet.com.au> schreef in bericht
> > > news:4e28e80.0402101740.6117cc7c@posting.google.com...
> > > > "Marcel" <neegeenspam@hotentottententententoonstellingen.nl> wrote in
> message news:<4028c8a6$0$64880$7eb43735@news.versatel.net>...
> > > > > "Shane C" <sclay@ceinternet.com.au> schreef in bericht
> > >........
> > > In your example you'll have to refer to orderno because that's the only
> > > unique key to find the right row...
> > >
> > > Marcel
> >
> > Yes orderno is unique in the Orders table in the database, but there
> > are multiple products possible for each orderno. Therefore on the form
> > I may have 3 table rows with orderno 29, then 5 table rows with
> > orderno 24 (depending on how many products were ordered per order).
> > If I referenced it by orderno alone, it will change the value for all
> > products in that order.
>
> So each product-row needs to have it's own unique id... otherwise updating a
> single row isn't possible
>
> Marcel
I'm obviously getting confused here, and in a bit of a mess.
Here is a sample of my form -
http://www3.ceinternet.com.au/~sharclay/displayform.jpg
I need to be able to change anything on this form, and click update to
update the database.
Here is my current version of the php code to update the form. It's a
bit of a mess.
<?
//This script takes the data from the form
//fields and adds them to specified parts
//parts of the database
//MySQL Variables.
$host = "localhost";
$login_name = "******";
$pass = "******";
//Connecting to MYSQL
MySQL_connect("$host","$login_name","$pass");
//Select the database we want to use
MySQL_select_db("avon") or die("Could not select database");
$custid = $HTTP_POST_VARS['custid'];
$name = $HTTP_POST_VARS['name'];
$address = $HTTP_POST_VARS['address'];
$phone = $HTTP_POST_VARS['phone'];
$age = $HTTP_POST_VARS['age'];
$sql = "UPDATE customers SET name='$name',address='$address',
phone='$phone', age='$age' where custid='$custid'";
$arr_orderno=$orderno[$i];
$arr_productid=$productid[$i];
$arr_campaign=$campaign[$i];
$arr_date=$date[$i];
$arr_productname=$productname[$i];
$arr_quantity=$quantity[$i];
$arr_salesprice=$salesprice[$i];
$rows = $productid;
for ($i=1;$i<= $rows;$i++){
$sql = "UPDATE orders SET campaign = '$arr_campaign' where custid
='$custid' and orderno='$arr_orderno'";
}
echo ($sql);
if ( mysql_query($sql) ) {
echo ("User <b>$name</b> updated successfuly");
echo("<P>(Update affected " . mysql_affected_rows() . "
rows.)</P>");
}
else
{ echo("<P>Error performing update: " . mysql_error() .
"</P>");
}
//Close connection with MySQL
MySQL_close()
?>
- Next message: paulm844: "Repeat Region in Dreamweaver MX"
- Previous message: - Dazed: "mod_rewrite help requested, please"
- In reply to: Marcel: "Re: Updating multipile rows from an order history form ( ie same id)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|