Passing variables between methods
Passing variables between methods
<?php
class MIT_DB
{
private $cxn;
function __construct()
{
$this->cxn = new mysqli('localhost', 'root', 'password', 'db') or die('Couldn\'t connect to the database');
}
function query()
{
$query = 'SELECT id, name, description FROM data_table';
if($stmt = $this->cxn->prepare($query))
{
$stmt->execute();
$stmt->bind_result($id, $name, $description);
$stmt->fetch();
}
else
{
echo '<p>There was no content in the database</p>';
}
}
function loadAssoc()
{
while($row = $stmt)
{
echo "<p>$name</p>";
echo "<p>$description</p>";
}
}
}
?>






Cartoon Clouds
Mountains
Sunrise
Clouds
Green Clouds
None














Help