简体   繁体   English

无法从mysql表访问所有数据

[英]Having trouble accessing all data from mysql tables

Im trying to run a query that will echo the rowcount from the databse. 我试图运行一个查询,该查询将从数据库返回行数。 at the moment it only shows the last one not all of them. 目前,它仅显示最后一个而不是全部。 Can someone please help me on how to show all the rows instead of just one. 有人可以帮我显示所有行而不是所有行。

    $search = $_GET['pc'];
$approved = 'Approved';
$live = 'Live';
$q = $handler->prepare("SELECT * FROM store WHERE pc = ? OR plus_1 = ? OR plus_2 = ? OR plus_3 = ? OR plus_4 = ?");
$q->bindParam(1, $search);
$q->bindParam(2, $search);
$q->bindParam(3, $search);
$q->bindParam(4, $search);
$q->bindParam(5, $search);
$q->execute();
if($q->rowCount() > 0){
    while($r = $q->fetch()){
        $local_id = $r['user_id'].;
    }

    $q = $handler->prepare("SELECT * FROM users WHERE id = ? AND status = ?");
    $q->bindParam(1, $local_id);
    $q->bindParam(2, $approved);
    $q->execute();
    if($q->rowCount() > 0){
    while($r = $q->fetch()){
        $local_id_2 = $r['id'].;
    }

        $q = $handler->prepare("SELECT * FROM offers WHERE user_id = ? AND status = ? AND approved = ?");
        $q->bindParam(1, $local_id_2);
        $q->bindParam(2, $live);
        $q->bindParam(3, $approved);
        $q->execute();



echo        $viewAll = $q->rowCount();

    }
}

if tried echoing all the $local_id and local_id2 but only the first one ($local_id) echos all of the data the rest just echos the last $lcoal_id from the first one.. Thanks in advance. 如果尝试回显所有$ local_id和local_id2,但只有第一个($ local_id)回显所有数据,其余的仅回显第一个的最后一个$ lcoal_id。

将使用临时修复程序来创建另一个包含我需要的所有数据的表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM