[ILUG] fetch_row problem
marmbrecht at eircom.net
Sun Mar 28 00:11:21 GMT 2004
Am Samstag, 27. März 2004 23:00 schrieb nils:
> can anyone see anything wrong with this.
> $result = mysql_query("SELECT topic_id, forum_id, topic_last_post_id,
> topic_title, topic_poster, topic_views, topic_replies,topic_moved_id
> FROM phpbb_topics ORDER BY topic_last_post_id DESC");
> This should put the return array into each var listed.
Am I correct in assuming that the language you are talking about is actually
> while(list($topic_id, $forum_id, $topic_last_post_id, $topic_title,
> $topic_poster, $topic_views, $topic_replies, $topic_moved_id) =
> but when i do echo $topic_id, i get no value returned.
Which is no surprise, really, because the body of the while loop is empty.
Your while loop keeps looping until the list() function returns false, which
is at the end of your result set, and in this case there are no more rows to
be retrieved, so your variables don't contain anything.
> but if i change the the while for this i get back
> $myrow = mysql_fetch_row($result);
> echo "<pre>";
> echo "</pre>";
> I get this back
>  => 26
>  => 12
>  => 65
>  => vega strike
>  => 6
>  => 1
>  => 0
>  => 0
Yes, but this time you don't loop, but print out the first result row.
while(list($topic_id, $forum_id, $topic_last_post_id, $topic_title,
$topic_poster, $topic_views, $topic_replies, $topic_moved_id) =
instead. This should print out a list of topic_id, assuming that your query
actually returns at least one row.
War is peace. Freedom is slavery. Ketchup is a vegetable.
More information about the ILUG