PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?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 "<h3><a href=\"index.php?content=answers&cat=$topic_id\">$problem</a></h3><br>\n";
}
?>
But returns repeadeatly the same problems in each topic.... how i can fix it. ... thanks for you cooperation
Last edited by Benjamin on Mon Nov 14, 2011 10:56 pm, edited 1 time in total.
Reason:Added [syntax=php||htm||css||javascript||sql||etc] - Please use [syntax] tags when posting code in the forums! Thanks.
don't assign it to a var in the while statement if you are going to echo it out at the same time also I always surround my queries with single quotes when using =, just use
$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_assoc($result))
{
echo "<h3><a href='index.php?content=answers&cat=".$topic_id."'>".$row['problem']."</a></h3><br>\n";
}
?>