|
Posted by Schraalhans Keukenmeester on 05/16/07 20:13
At Wed, 16 May 2007 12:37:29 -0700, Akhenaten let his monkeys type:
> This sql query is good but I'm having trouble echoing the results with
> php (no data echoed). Suggestions?
>
> *************
> $open_C = 'select * '
> . ' from questions , users '
> . ' where users . username = "X" LIMIT 0, 30 ';
>
> // Fetch each row of the results into an array $q_row
> while ($q_row = @mysql_fetch_array($open_C))
> {
> echo "ID:\t{$q_row['question']}\n";
>
> }
>
> *************
>
> Thank you.
You have to open a connection to the db and execute the query first, then
fetch rows on the result resource:
<?PHP
$conn = @mysql_connect($host,$user,$pass)
or die (mysql_error());
@mysql_select($dbname)
or die (mysql_error());
$result = mysql_query($open_C, $conn)
or die (mysql_error());
while ($row = mysql_fetch_assoc($result))
// use mysql_fetch_assoc to get the associative array only.
{
echo "ID:\t{$q_row['question']}\n";
}
?>
HTH
Sh.
[Back to original message]
|