On Sun, 10 Aug 2003 22:11:09 +0100, you wrote:

>I have a sql statement which brings about 15 records... inside the while
>loop i am trying to get data from another table by passing an id, the
>problem is i am only getting the first record .. not the whole 15 records..
>
>any suggestion??
>
>function list_ss_cats(){
>global $db;
>$sql = "SELECT DISTINCT(new_cat) FROM logos WHERE format =3";
>$result = $db->sql_query($sql);
>$num = $db->sql_numrows();
>while($row = $db->sql_fetchrow()){
>
> $sql2 = "SELECT * FROM cats WHERE id='$row[new_cat]'";

Others have answered your immediate question, but it looks to me like you
should be doing a join and only using one SQL statement instead of sixteen.
Something along the lines of

SELECT DISTINCT(logos.new_cat), cats.*
  FROM logos, cats
  WHERE logos.format = 3
  AND logos.new_cat = cats.id

(Though I'd remove the * personally, it can slow things down. Oh, and you
get $num but never actually use it, and "$row1[en]" should be throwing a
warning - it should be "$row1['en']").


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to