RE: [PHP] Multiple database seeking

From: Date: Tue, 04 Dec 2001 02:54:10 +0000
Subject: RE: [PHP] Multiple database seeking
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-76455@lists.php.net to get a copy of this message
Something like this for the SQL SELECT ( t1.price + t2.price ) as total FROM table t1, table t2 WHERE t1.id=1 AND t2.id=5; Jason Lotito jason@lehighweb.com www.NewbieNetwork.net > -----Original Message----- > From: Alen Nonkoviè [mailto:alen.nonkovic@uni-mb.si] > Sent: Monday, December 03, 2001 9:31 AM > To: php-general@lists.php.net > Subject: [PHP] Multiple database seeking > > > Hello, > > I am trying to make a something like a cooking recipe with > some calculations. My problem is too much database querying. > Is it really a problem??? > > Let's suppose there is a table with items and prices: > item1 price1 > item2 price2 > item3 price3 > ... > > Then I have to calculate some new indegrient price, which is > a result of calculating other prices: > (ex: $new_price1 = 2*$price1 + $price2 ) > > To get wanted prices I used standard query: > ---------------------------------------------------- > > $result = mysql_query ("SELECT price from price_list where > id = '01'"); $row = mysql_fetch_array($result); $price1 = > $row["price"]; > > $result = mysql_query ("SELECT price from price_list where > id = '02'"); $row = mysql_fetch_array($result); $price2 = > $row["price"]; > > //...and so on for about 30 indegrients. > > And on the end: > $new_price1 = 2*$price1 + $price2; > print "$new_price1"; > > ---------------------------------------------------------- > > But, is there a quicker way to do this? Am I doing maybe the > wholistic mistake in process? Or this is just OK? > > Please, help cooking the soup ;) > > regards, > Alen > > >

« previous php.general (#76455) next »