Page is a not externally linkable
- Code, Content, and Presentation
-- Databases
---- problem with mysql fetch array


rocknbil - 1:49 am on Jul 28, 2010 (gmt 0)


There is no COUNT(novicaID) field in that query. Try this. You will no longer have to echo zero . . . or if you do, you can do it like so . . . .

$query = "select (select count(*) from novice_komentarji where novice_komentarji.novicaID=novice.id) as postcount, novice.id, novice.naslov from novice";


$asql = mysql_query($query) or die (mysql_error());
while ($abc = mysql_fetch_array($asql)) {
if($abc['postcount'] > 0) {
echo $abc['postcount'] . " comments";
}
else {
echo "No new comments";
}
}


Should be a copy and paste, of course, translate as required. :-)


Thread source:: http://www.webmasterworld.com/databases_sql_mysql/4175730.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com