🔒 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
  • 418
    Views
  • 2
    Participants
Last reply from:
ShiroyashaX

Trending Topics

Online now

Members online
1,314
Guests online
3,538
Total visitors
4,852

Forum statistics

Threads
2,305,826
Posts
29,168,073
Members
1,195,464
Latest member
tibolok
Back
Top