🔒 Closed How to display manually PDO

Status
Not open for further replies.

Pusoy000

Forum Veteran
This is my code
Code:
<?php
    include_once('includes/initialize.php');     
 
        $usn = "aa";   
        $getUsers = $DB->query("SELECT * FROM tbl_student WHERE usn=?", array($usn));
        var_dump($getUsers);
        
?>
OUTPUT :
572040

Okay naman pag dinidisplay ko sha as var_dump() or print_r
Gusto ko sana display in rows manually kaso di ko alam nag eerror nka function namo kasi yan ang problema kolang ay pag display huhu
example: echo $row['firstname'];

sana may makatulong
 
Code:
$usn = "aa";   

$stmt = $DB->prepare('SELECT * FROM tbl_student WHERE usn = :usn');
$stmt->bindParam(':usn', $usn);
$stmt->execute();
$result = array();
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
    $result[] = $row;
}

foreach ($result as $student) {
    echo "Username: " . $student['usn'] . "\n";
    echo "Name: " . $student['fname'] . $student['mname'] . $student['lname']. "\n\n";
}

Try mo TS.
 
Status
Not open for further replies.

About this Thread

  • 1
    Replies
  • 389
    Views
  • 2
    Participants
Last reply from:
ShiroyashaX

Trending Topics

Online now

Members online
1,150
Guests online
1,081
Total visitors
2,231

Forum statistics

Threads
2,274,699
Posts
28,957,709
Members
1,233,404
Latest member
Carameltzy
Back
Top