atfOnly Posted July 14, 2011 Share Posted July 14, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/241961-store-total-number-of-mysql_num_rows-into-array/ Share on other sites More sharing options...
harristweed Posted July 14, 2011 Share Posted July 14, 2011 I'm not sure but I think the problem is the isset! Try changing to : if(!empty($period[$i])|| !empty($gpa[$i]) || !empty($antecedent[$i])){ Quote Link to comment https://forums.phpfreaks.com/topic/241961-store-total-number-of-mysql_num_rows-into-array/#findComment-1242602 Share on other sites More sharing options...
atfOnly Posted July 14, 2011 Author Share Posted July 14, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/241961-store-total-number-of-mysql_num_rows-into-array/#findComment-1242667 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.