What's new

Closed How to display manually PDO

Status
Not open for further replies.

Pusoy000

Forum Veteran
Joined
Jan 30, 2017
Posts
1,645
Reaction
963
Points
667
Age
25
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
 

Attachments

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.
Back
Top