Jump to content

store total number of mysql_num_rows into array?


atfOnly

Recommended Posts

I don't know what's wrong with this code. I think this code should work. I'm about to store number of each query in array

 

$antecedent=array();

for($i=0;$i<=$index;$i++){
if(isset($period[$i])|| isset($gpa[$i]) || isset($antecedent[$i])){
	echo $period[$i]." ";
	echo $gpa[$i]."<br/>";
  $queryAntecedent=mysql_query("SELECT * FROM mytable WHERE  study_period='$period[$i]' AND ipk='$gpa[$i]'") or die (mysql_error());	

	$antecedent[$i]=mysql_num_rows($queryAntecedent);
	}//endif
}//endfor

print_r ($antecedent);

 

when i print_r $antecedent, its output is all zero for every element. i've tried to run the query in phpmyadmin and the result is not zero..i got some rows of result.

 

i've echo $period[$i] and $gpa[$i], it printed the results.So, i think there's no problem with the the values of those two array.

 

So, why can't i get the total rows of query? why all element in antecedent array only gives me 0 number?Please help!

 

Thank you  :D

I tried to put only one array in query sintax...it works!!

 

 $queryAntecedent=mysql_query("SELECT * FROM mytable WHERE  study_period='$period[$i]'") or die (mysql_error());

 

what happen? how to solve this? I need to put two arrays in the query

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.