Reply to Re: MySql count

Your name:

Reply:


Posted by BKDotCom on 11/20/06 22:55

I created a function get_query_rows() that makes the repetitive task of
using mysql_query() and looping through abnd getting the results easier
(for me anyhow).


$arr = array ("A", "B", "C", "D", "E");
foreach ($arr as $client)
{
$query = 'SELECT COUNT(*) as count from table where columnA =
"'.$client.'"';
$rows = get_query_rows($query);
$count = $rows[0]['count'];
echo "$client has $count<BR />";
}

function get_query_rows($query,$resource=null)
{
$rows = false;
$result = ( $resource )
? @mysql_query($query,$resource)
: @mysql_query($query);
if ( $result )
{
$rows = array();
$num_rows = mysql_num_rows($result);
for ( $i=0; $i<$num_rows; $i++ )
$rows[] = mysql_fetch_assoc($result);
}
else
trigger_error(mysql_error());
return $rows;
}

[Back to original 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

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