retrieven information for mysql database

I have the following tables: topic table: topic_id, sub_id, topic and problem table: problem_id, topic_id, problem. I want to retrieve the problems for every topic using the following code

<?php login(); $topic_id = $_GET['cat']; $query="SELECT problem_id, problem from problems WHERE topic_id=$topic_id ORDER BY problem ASC"; $result=mysql_query($query); while($row=mysql_fetch_array($result,MYSQL_ASSOC)) { $problem_id = $row['problem_id']; $problem = $row['problem']; echo "

$problem


\n"; } ?>

but only returns the same problems in each topic… how i can fix it. Thank you for you cooperations

Check that in your database the entries don’t all have the same topic_id.

Sponsor our Newsletter | Privacy Policy | Terms of Service