Okay, I went a little further. I got a new fatal error.
Cannot redeclare DB:😛repare() on line 17
By the way, thanks for that.
<html>
<head>
<title>Student List</title>
</head>
<?php
include('./includes/config.inc');
include('./includes/db.php');
$db->store_sql('SELECT fname, lname from students ORDER BY lname','student_list' );
$result = $db->multi_query($query) or die($db->error());
while ($row = $result->fetch_assoc()) {
**********
foreach($row as $key=>$value) {
echo ''.$key.': '.$value.'';
}
echo ' ';
}
?>
---------functions------------
<?php
class DB {
public function __construct(mysqli $mysqli) {
$this->mysqli = $mysqli;
}
//existing DB class
public function prepare ( $query = '' ) {
return new PS( $this, $query );
}
//put this function as a method in your
//existing DB class
public function prepare ( $query = '' ) {
return new PS( $this, $query );
}
}
class PS extends mysqli_stmt {
public function construct ( $mysqli, $query ) {
parent::construct( $mysqli, $query );
}
function rs($sql) {
//add error handler to show query and error
$this->result = $this->mysqli->query($sql) or die(mysqli_error($this->mysqli));
return $this->result->fetch_assoc();
}
function prepared_query_result($sql, $bind_param) {
$this->stmnt = $this->mysqli->prepare($sql);
$this->stmnt->bind_param("s", $bind_param);
$this->stmnt->execute();
$this->stmnt->bind_result($result);
$this->stmnt->fetch();
$this->stmnt->close();
return $result;
}
}
?>