[PHP-DB] help with loop and query
Hi guys, Hopefully last time I need to call of you people for this report I am creating. In this report there is a multiple select box like: Province/State Alaska Alberta British Columbia California Colorado Connecticut Using this select box comparison data for each of the selected provinces where an order was placed is supposed to be displayed. For example if Alaska, Alberta and British Columbia were selected 1) Grab all cart_ids from the OrderTable for each province 2) Reference the cart_id from the OrderTable to the cart_id in the CartTable 3) Display results and products order totals for each province individually. Illustration: Product | Total Orders | Total Sold | Dollar Total Pronvince Name: Alaska Product 1 | 12 | 350 | $3215.45 Product 2 | 8 | 123 | $2143.23 Product 3 | 14 | 113 | $6412.43 Pronvince Name: Alberta Product 1 | 5 | 87 | $1215.45 Product 2 | 3 | 23 | $143.23 Product 3 | 7 | 101 | $5412.43 Pronvince Name: British Columbia Product 1 | 6 | 71 | $1015.45 Product 2 | 25 | 66 | $643.23 Product 3 | 3 | 23 | $412.43 Hopefully you can see what I am trying to do here. Here is the code I have been working this thus far.. ** CODE ** % Ive been able to get the cart_ids associated with each province selected but I am having lots of trouble displaying the result FOR the selected $provinces. Can anyone help me with where I am erroring? Thanks a ton! Aaron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Help with loop
Thanks a million, works great now. - Original Message - From: "Mark Newnham" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 25, 2001 1:41 PM Subject: RE: [PHP-DB] Help with loop > $res = mysql_query("SELECT * FROM ecomm where ID ='$sid'",$db)) > if(!$res){echo("error preforming query: " . mysql_error());exit();} > //error trap > while( $row=mysql_fetch_array($res)){ > $pno=$row["part"]; > > > # > Mark Newnham > Application Design Associates, Inc > 6021 S.Syracuse Way #302 > Englewood, CO 80111, USA > > http://www.adacorp.com > # > > > > > -Original Message- > > From: Robert [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, January 25, 2001 12:31 PM > > To: [EMAIL PROTECTED] > > Subject: [PHP-DB] Help with loop > > > > > > Why does this spit out the same part over and over until it times out? > > > > I have 2 tables in the same database > > > > 1: bruindba <---Parts database > > specific_p <Part Number > > manufactur <---Manufacturer > > package <---Package in > > > > 2: ecomm <---Ecommerce database > > ID <---session ID random number generated > > when first part is entered > > part <---Part number > > > > What I am trying to do is store the part numbers with the > > session ID in ecomm and then pull all of them > > out with descriptions from bruindba. > > > > //- Get parts for this session > > > > // Check ecomm DB for parts by session ID > > --- > > while ($res = mysql_query("SELECT * FROM ecomm where ID > > ='$sid'",$db)){ > > if(!$res){echo("error preforming query: " . > > mysql_error());exit();} //error trap > > $row=mysql_fetch_array($res); > > $pno=$row["part"]; > > > > //-Get part info from bruindba > > --- > > $result = mysql_query("SELECT * FROM bruindba where > > specific_p ='$pno'",$db); > > if(!$result){echo("error preforming query: " . > > mysql_error());exit();} //error trap > > $row=mysql_fetch_array($result); > > $spp=$row["specific_p"]; > > $mfc=$row["manufactur"]; > > $pkg=$row["package"]; > > echo" $spp"; > > echo" $pkg"; > > echo" $mfc"; > > } > > > > > > Thanks for any help you can provide -Bob- > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Help with loop
$res = mysql_query("SELECT * FROM ecomm where ID ='$sid'",$db)) if(!$res){echo("error preforming query: " . mysql_error());exit();} //error trap while( $row=mysql_fetch_array($res)){ $pno=$row["part"]; # Mark Newnham Application Design Associates, Inc 6021 S.Syracuse Way #302 Englewood, CO 80111, USA http://www.adacorp.com # > -Original Message- > From: Robert [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 25, 2001 12:31 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Help with loop > > > Why does this spit out the same part over and over until it times out? > > I have 2 tables in the same database > > 1: bruindba <---Parts database > specific_p <Part Number > manufactur <---Manufacturer > package <---Package in > > 2: ecomm <---Ecommerce database > ID <---session ID random number generated > when first part is entered > part <---Part number > > What I am trying to do is store the part numbers with the > session ID in ecomm and then pull all of them > out with descriptions from bruindba. > > //- Get parts for this session > > // Check ecomm DB for parts by session ID > --- > while ($res = mysql_query("SELECT * FROM ecomm where ID > ='$sid'",$db)){ > if(!$res){echo("error preforming query: " . > mysql_error());exit();} //error trap > $row=mysql_fetch_array($res); > $pno=$row["part"]; > > //-Get part info from bruindba > --- > $result = mysql_query("SELECT * FROM bruindba where > specific_p ='$pno'",$db); > if(!$result){echo("error preforming query: " . > mysql_error());exit();} //error trap > $row=mysql_fetch_array($result); > $spp=$row["specific_p"]; > $mfc=$row["manufactur"]; > $pkg=$row["package"]; > echo" $spp"; > echo" $pkg"; > echo" $mfc"; > } > > > Thanks for any help you can provide -Bob- > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Help with loop
Why does this spit out the same part over and over until it times out? I have 2 tables in the same database 1: bruindba <---Parts database specific_p