prepare($query);
$argcount = func_num_args();
$arglist = func_get_args();
for ($x = 1; $x < $argcount; $x++) { $stmt->bindParam($x, $arglist[$x]); }
$stmt->execute();
if (strpos($query,'select') !== false)
{
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$data = $stmt->fetchAll();
return $data;
}
$conn = null;
}
function render2($template)
{
$arglist = func_get_args();
include "html/" . $template;
}
include "lib/functions.php";
$results = query("select * from DOCTORS");
$template = "doctors.html";
render2($template, $results);
?>
Copy 2
Copy 3
";
class TableRows extends RecursiveIteratorIterator {
function __construct($it) {
parent::__construct($it, self::LEAVES_ONLY);
}
function current() {
return "" . parent::current(). " | ";
}
function beginChildren() {
echo "";
}
function endChildren() {
echo "
" . "\n";
}
}
$connost = "instruct.coe.neu.edu";
$dbname = "3425flavdas";
$dbuser = "3425flavdas";
$dbpass = "B4BehqYU";
$servername = "instruct.coe.neu.edu";
$username = "3425flavdas";
$password = "B4BehqYU";
$dbname = "3425flavdas";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM EDUCATION");
$stmt->execute();
// set the resulting array to associative
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
echo $v;
}
$dsn = null;
}
catch(PDOException $e)
{
echo "Error: " . $e->getMessage();
}
$conn = null;
echo "";
?>