I’m new to PDO having used mySQL in the past. Currently I have managed to get the table from the database printed out and displaying one course at a time. I need to print all of the courses.
Here is my current code:
[code]<?php
require_once(‘connect.php’);
$sql = “SELECT CourseID, Course_Name FROM coursename WHERE CourseID = :CourseID”;
$stmt = $db->prepare($sql);
$CourseID = 1;
$stmt->bindParam(’:CourseID’, $CourseID, PDO::PARAM_INT);
$stmt->execute();
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
print_r($results);
?> [/code]
This outputs “Array([0] => Array ( [CourseID] => 1 [Course_Name] => Computing ) )” I have tried to implement a while loop with no success.
Any help would be appreciated.