Re: Updating multipile rows from an order history form ( ie same id)

From: Shane C (sclay_at_ceinternet.com.au)
Date: 02/12/04


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()
?>



Relevant Pages

  • Updating multipile rows from an order history form ( ie same id)
    ... CUSTOMERS PRODUCTS ORDERS ORDERDETAILS ... custid* productid* orderno* orderno ... I have forms to interact with the database to add/search/display etc. ... hidden form field 'custid' to link the data, but am not sure how to ...
    (alt.php)
  • Re: How to lock an MSSQL server recordset for read?
    ... I have a database which has several tables. ... I need to get the first available OrderNo from this table, ... In most cases if you open the recordset using a server-side keyset cursor, ... the value of the identity column will be available in the recordset after ...
    (microsoft.public.data.ado)
  • Re: How to lock an MSSQL server recordset for read?
    ... I need to get the first available OrderNo from ... since there are multiple programs doing this simultaneously I have ... to set the Available column and update the database one or more other ... What you need to do is to start a transaction when you ...
    (microsoft.public.data.ado)
  • Re: sql select statement not working
    ... Is OrderNo a numeric or text field? ... Sue Mosher, Outlook MVP ... > I am taking information from a custom form i.e. order ... > select that order form the database. ...
    (microsoft.public.outlook.program_forms)
  • Re: MySQL Database problem (probably already solved in a message, but this is somewhat urgent)
    ... MySQL server has a database with a table, ... columns, an FSR column, and a password column. ... checked if the supposed arrays that were returned were actually arrays ...
    (comp.lang.php)