PHP - Too many mysql_query("SELECT .. ") .. ?
Posted
by Mike
on Stack Overflow
See other posts from Stack Overflow
or by Mike
Published on 2009-10-04T17:21:28Z
Indexed on
2010/05/04
18:28 UTC
Read the original article
Hit count: 271
Hey, I'm making an e-shop and to display the tree of categories and all the products with their multiple variations of prices I made like more than 150 mysql_query("SELECT ...");
queries on one page. (If I count the "while" loops).
Is it too many, and if yes, can it have any negative effect? (ofc. it takes longer to load the data ..)
Also can I anyhow achieve the effect of this code without doing it that way?
$result2 = mysql_query("SELECT * FROM ceny WHERE produkt_id='$id' ORDER BY gramaz");
$result3 = mysql_query("SELECT * FROM ceny WHERE produkt_id='$id' ORDER BY gramaz");
$result4 = mysql_query("SELECT * FROM ceny WHERE produkt_id='$id' ORDER BY gramaz");
$result5 = mysql_query("SELECT * FROM ceny WHERE produkt_id='$id' ORDER BY gramaz");
while( $row2 = mysql_fetch_array( $result2 )) { }
while( $row3 = mysql_fetch_array( $result2 )) { }
while( $row4 = mysql_fetch_array( $result2 )) { }
while( $row5 = mysql_fetch_array( $result2 )) { }
Thanks, Mike.
© Stack Overflow or respective owner