我有2个表question_details
和paid_response
question_details
包含
qno qshortcode
504 what do you want
515 what is your name
541 what is your address
.
.
other.. others question
paid_response
包含
qno paid_respo paid_rev sys_date
504 yes 0.60 2014-12-16 04:14:40
515 no 0.42 2014-12-17 04:14:40
现在我希望来自qshortcode
的{{1}}来自question_details
而来自qno(504 and 515)
表的paid_respo,其中paid_rev不是= 0.00且两个日期之间
paid_response
我的提取what do you want what is your name //fetching from `question_details` table
yes no //fetching from `paid_response` table with respect to `qno` where paid_rev not 0.00
question_details`表的代码
qshortcode from
它的提取类似
<?php
//DB connection goes here
$query=mysql_query("select qshortcode from question_details where qno=504 or qno='515'");
echo '<tr>';
for($i = 0; $row = mysql_fetch_array($query);$i++) {
echo '<td>'.$row['qshortcode'].'</td>';
echo '</tr>';
} ?>
答案 0 :(得分:1)
尝试使用此方法:使用加入来合并这两个表
<?php
//DB connection goes here
$query=mysql_query("select qshortcode,paid_respo from question_details left join paid_response on paid_response.qno=question_details.qno where question_details.qno in (504,515)");
echo '<table>';
while ($row = mysql_fetch_array($query)) {
echo '<tr>';//to show each response as one row.
echo '<td>'.$row['qshortcode'].'</td>';//what do you want
echo '<td>'.$row['paid_respo'].'</td>';//yes
echo '</tr>';
}
echo '</table>'
?>