"Cody Law" <[EMAIL PROTECTED]> wrote:
>      When you do a query inside a while loop in PHP,
> does it dramatically slow down the loading of the
> page? For example,
>
> while($row = mysql_fetch_row($result)) {
>  $id = $row[0];
>  $query2 = "select field from some_table
> where(id='$id')";
>  $result2 = mysql_result($query2, $link);
> }

It will take longer, whether it's dramatically longer depends on a lot of
things.  In your case the inner query will be fast if the id field ia a key
of an index, but since it has to be run once for every record returned from
the outer query there might be a better way.  If possible, try to use the
LEFT JOIN syntax to get the data you want from a single query.  LEFT JOIN
syntax is covered in the online manual and the list archives.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to