Mr Blue Mr Blue - 2 years ago 86
SQL Question

How to echo row from custom statement another than $stmt

My code :

$stmt = $user_home->runQuery("SELECT * FROM tbl_users, tbl_products WHERE userID=:uid and creatorID=:uid");
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$scheck = $user_home->runQuery("SELECT * FROM tbl_products WHERE serialNumber=:snr");

How to echo row from $scheck?

When I type
it's showing row from $stmt.

I try to do
but it does not show anything.

I tried to find answer in google, but I did not find the solution.

Answer Source

When you are already using fetch on another statement above, why cant you use it here too?

$scheckrow = $scheck->fetch(PDO::FETCH_ASSOC);

Then you can simply do what you're already doing

echo $scheckrow['artNumber'];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download