php-db | 2001011
Date: 01/08/01
- Next message: Rasmus Lerdorf: "Re: [PHP-DB] Stupid newbie looping MySQL question"
- Previous message: Lynn Siprelle: "Re: [PHP-DB] Stupid newbie looping MySQL question"
- In reply to: Lynn Siprelle: "[PHP-DB] Even weirder!"
- Next in thread: Lynn Siprelle: "RE: [PHP-DB] Stupid newbie looping MySQL question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Lynn Siprelle wrote:
>
> OK, fooling around, I came up with the following (after routines to connect with the db etc):
>
> $myquery="SELECT name FROM forums";
> if(!$result = mysql_db_query("tnh", $myquery)); {
> print("Error performing statement ");
> printf("error: %d %s", mysql_errno($link), mysql_error($link));
> }
>
> while($row=mysql_fetch_object($result)) {
> $nextquery = "SELECT id, datestamp, thread, subject, author FROM $row->name ORDER BY datestamp ASC LIMIT 0, 20";
>
> $sSQL = mysql_fetch_array($nextquery); //this is line 30 in the script
> if (!$s_row = mysql_fetch_object($sSQL)) { //...which makes this 31 :)
> print ("<b>In <a href=\"/phorum/list.php?f=$id\">$row->name</a></b>:</br>\n");
> print ("<font size=-1>Nothing new today.</font><br>\n");
> } else {
> print ("<b>In <a href=\"/phorum/list.php?f=$id\">$row->name</a></b>:</br>\n");
> while($s_row = mysql_fetch_object($sSQL)) {
> print ("<font size=-1>" . date_format($s_row->datestamp, '%b %e, %Y') . ": <a href=\"/phorum/read.php?f=$id&t=$s_row->thread&i=$s_row->id#i$s_row->id\">$s_row->subject</a>--$s_row->author</font><br>\n");
> }
> }
> }
That's quite an easy problem.
Line 30:
The $nextquery is a string. What you need for
mysql_fetch_array is something that comes from mysql_db_query.
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Rasmus Lerdorf: "Re: [PHP-DB] Stupid newbie looping MySQL question"
- Previous message: Lynn Siprelle: "Re: [PHP-DB] Stupid newbie looping MySQL question"
- In reply to: Lynn Siprelle: "[PHP-DB] Even weirder!"
- Next in thread: Lynn Siprelle: "RE: [PHP-DB] Stupid newbie looping MySQL question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

