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


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

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 :)

This happens because you can't access an array's members directly inside a double-quoted string.

You can either try like this


that might work, I'm not sure.

Or just do it like this


which will work for sure.

@Insensus: yes, first example will work.

Thanks for the suggestion, Insensus.i don't know.. but those two ways didn't work :(

must check the code over and over again.

another helps and suggestions are well-appreciated ;)

I think this is a bit strange..

when i only put one array in query sintax,like this...

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

the rest of code works.

but, when i put two arrays in query (like previous post), the rest of code doesn't work. How to solve this?

Thank you

Try taking one specific case of your query (choose a $period[$i] and $gpa[$i]) and run that query in phpmyadmin.
If it doesn't return anything there's obviously something wrong with your query.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.