没有得到正确的结果! [英] Not getting proper result!!
本文介绍了没有得到正确的结果!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2张桌子
问题(q_id,问题,部门)
answer(a_id,q_id,answer)
我希望当我单击特定部门时,它应该向我显示问题,然后它的答案(可以是一个以上),然后是下一个问题,如其答案在论坛中一样,但它没有这样做是在打印问题,那么与该部门相关的所有答案都不会q_id
I have 2 tables
question(q_id,question,dept)
answer(a_id,q_id,answer)
I want that when i click on particular dept than it should show me question then its answer(can be more than one ) then next question tthen its answer like in forums but its not doing it is printing question then all anwers related to that dept not q_id
<?php
$q=$_GET["q"];
$host="localhost";
$db_name="portal";
$tb_name="question";
$con=mysql_connect("$host","root","")or die("cannot connect");
mysql_select_db("$db_name",$con)or die("cannot connect");
$sql="SELECT question FROM question WHERE dept='".$q."'";
//$sql2="SELECT q_id FROM question WHERE dept='".$q."'";
$sql1="SELECT answer FROM answer WHERE q_id in (SELECT q_id FROM question WHERE dept='".$q."') " ;
$result= mysql_query($sql);
$result1= mysql_query($sql1);
while($row = mysql_fetch_array($result) )
{
echo "<br>";
echo "Q. ";
echo $row[0];
while($row1 = mysql_fetch_row($result1))
{
echo "<br>";
echo "Ans. ";
echo $row1[0];
}
}
推荐答案
q =
_GET ["span> q"];
host = 本地主机";
host="localhost";
这篇关于没有得到正确的结果!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文