使用一个查询从4个SQLite表中选择和回显具有相同ID的行

时间:2017-12-03 13:31:10

标签: php sqlite

我正在尝试使用PHP从四个表中选择具有相同id的数据。

这是PHP SELECT查询:

$logId = $_SESSION['log_id'];
$sql = $db->prepare("SELECT toexapp.*,toff.*,tolba.*,toibs.*
    FROM toexapp, toff, tolba, toibs
    WHERE toexapp.post_id = ? AND toff.post_id = ? AND tolba.post_id = ? AND toibs.post_id = ?");
$sql->bindParam(1, $logId, SQLITE3_INTEGER);
$sql->bindParam(2, $logId, SQLITE3_INTEGER);
$sql->bindParam(3, $logId, SQLITE3_INTEGER);
$sql->bindParam(4, $logId, SQLITE3_INTEGER);
$result = $sql->execute();

while ($row = $result->fetchArray(SQLITE3_ASSOC)) 
{
    $req_id = $row['req_id'];
    $req_title = $row['req_title'];
    $min_order = $row['min_order'];
    $poi = $row['poi'];
    $pay_method = $row['pay_method'];
    $req_brief = $row['req_brief'];
    $post_id = $row['post_id'];
    $_SESSION['post_id'] = $post_id;
    $_SESSION['req_id'] = $req_id;
    $towho = $row['towho'];
    $commodityimg = $row['commodityimg'];

    echo '<form action="deletepost.php" method="post" enctype="nultipart/form-data">
    <div class="postSlate">
                            <input style="display: none" type="submit" name="deletepost" id="deletepost" value="Delete">
                        <label for="deletepost"><i class="typcn typcn-delete clsup2"></i></label>
                            <input type="text" style="display: none" name="reqid" class="reqid" value="'.$req_id.'">
                        </form>
                <ul class="slateDetails"><a href="userprofile.php?userid='.$post_id.'"><li><img class="exdetails" src="'.$profimages.'"></li><li>'.$cname.'</li></a></ul>
                <div class="slateImg"><img src="'.$commodityimg.'"></div>
                <div class="slateTitle extitle"><p>'.$req_title.'</p></div>
                <div class="slateBrief"><p>'.$req_brief.'</p></div>
                <div class="slateBtn">
                </div>
                </div>';
}

我有四个表,在一个查询中我只有一个SELECT FROM WHERE post_id = $logID,但我当前的查询当前echo没有任何错误。我该如何解决这个问题?

0 个答案:

没有答案