HormonX
10-13-2002, 03:07 AM
This is fairly simple... but for some reason i have a problem ( as always ) :)
ok .. i have a pull down menu with questions, if i select a question from a list an answer should be pulled form the database and displayed on thesame page .
I have go the menu to display the questions, the problem i have is with displaying the answers. below is the code for pulling the questions from the database
<?
include ('connect.php');
$query = "SELECT * FROM faq";
$result = mysql_query( $query, $link );
?>
<option>Please Select a Question</option>
<?
while($r=mysql_fetch_array($result))
{
$faq_id=$r['faq_id'];
$q = $r['q'];
echo "<option value='faq.php?faq_id=$faq_id'>$q</option><br>";
}
?>
I came up with this code to get the answers .. but it still doesn't work.
if(!$faq_id)
{
echo "";
}
else
{
$query = "SELECT * FROM faq WHERE faq_id='$faq_id'";
$result = mysql_query( $query, $link );
while($r=mysql_fetch_array($result))
{
$a=$r['a'];
echo "$a";
}
and in fact nothing is displayed ... what am i missing ?
hope you can help
HormonX
ok .. i have a pull down menu with questions, if i select a question from a list an answer should be pulled form the database and displayed on thesame page .
I have go the menu to display the questions, the problem i have is with displaying the answers. below is the code for pulling the questions from the database
<?
include ('connect.php');
$query = "SELECT * FROM faq";
$result = mysql_query( $query, $link );
?>
<option>Please Select a Question</option>
<?
while($r=mysql_fetch_array($result))
{
$faq_id=$r['faq_id'];
$q = $r['q'];
echo "<option value='faq.php?faq_id=$faq_id'>$q</option><br>";
}
?>
I came up with this code to get the answers .. but it still doesn't work.
if(!$faq_id)
{
echo "";
}
else
{
$query = "SELECT * FROM faq WHERE faq_id='$faq_id'";
$result = mysql_query( $query, $link );
while($r=mysql_fetch_array($result))
{
$a=$r['a'];
echo "$a";
}
and in fact nothing is displayed ... what am i missing ?
hope you can help
HormonX