You are here: Re: PHP/MySQL array w/zero results « PHP Programming Language « IT news, forums, messages
Re: PHP/MySQL array w/zero results

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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация