Page 1 of 1

Weird mysql/php phpnuke query issue ?

Posted: Wed Nov 26, 2003 4:59 am
by fuzioneer
I use phpnuke and mysql on a website i run, i am fairly new to mysql/php coding and have encountered a weird issue that is probably soooooo easiy for a proper coder to resolve :)

Basically i have a field in one of my tables populated by INT numbers, i want to grab the field count from the row that equates to an array element and display it. The grabbing works and it seems to find the field count values ok, but doesn't display them correctly, instead i get a list of my fields i.e. 1,2,3 etc and they all have a [0] which is correct apart from the one that is supposed to be the value 3 but instead i just get [] !!!
any ideas ??

Code: Select all

$theArray=array("1","2","3","4","5","6","7","8");
$countarray=count($theArray)-1;
$content  = "<table width="65%" align="center" border="1" cellpadding="0" cellspacing="0">";
$x=0;
for ($x=0;$x<=$countarray;$x++) &#123;
	$sql = $db->sql_query ( "SELECT count AS the_count FROM mytbl where test='$theArray&#1111;$x]'" );
	$result = sql_fetch_array($sql);
	$total_count = $result&#1111;the_count];
	$content .= "<tr><td size="50%"><strong><big>&middot;</big></strong>$theArray&#1111;$x]</td><td size="50%" align="center">&#1111;$total_count]<br>";
	$total_count=="0";
&#125;

Posted: Wed Nov 26, 2003 5:41 am
by Weirdan

Code: Select all

SELECT count(*) AS the_count FROM mytbl where test='$theArray&#1111;$x]'
?

Posted: Wed Nov 26, 2003 6:04 am
by fuzioneer
nope that code snippet makes all the counts appear to be "[1]" when they should be "[0]" except for the count that should be 3 which now displays [1]