Can somebody help me what i'm doing wrong? The value from database is not visible when using:
<?php
$artikel = new Artikel();
$content= $artikel->printArtikel();
echo $content;
?>
<?php
class Artikel {
// db connection
protected $mydb;
// database value
protected $land;
public function __construct($artikelnummer = false)
{ // databaseconnection:
$this->mydb = new MyDB();
if($artikelnummer)
{
$this->load($artikelnummer);
}
else // load everything from database.
{
$sql = "SELECT * FROM artikel";
$this->mydb->doQuery($sql);
$this->mydb->close();
}
}
public function load($artikelnummer)
{
$sql = "SELECT * FROM artikel";
$this->mydb->doQuery($sql);
if($artikel = $this->mydb->fetch())
{
// i got a feeling there is something missing here, like query from database??
}
$this->mydb->close();
}
public function printArtikel()
{
// return database value as table.
$html = "<table border='1'>";
$html .= "<tr>
<td>".$this->land."</td>
</tr>";
$html .= "</table>";
return $html;
}
}
?>
Other class are accessing extern. For example database connection with class MyDB.
please, can somebody correct my script??