I'm trying to make a 'log' for a litte project.
The info what has to be in the log is in a other table in the database, I would like to get the html form from the database with the variable info in it which it takes from the other table.
Code which is in the Database:
<div class="container">
<ul class="timeline">
<li>
<div class="timeline-panel">
<div class="timeline-heading">
<h4 class="timeline-title"><?php echo $player->name ?></h4>
<p class="text-muted"><?php echo $player->time ?></p>
</div>
<div class="timeline-body">
<p>While slaying <?php echo $player->npcName ?> I found an <?php echo $player->drop ?>!</p>
</div>
</div>
</li>
</ul>
Class with functions:
class player
{
public $name;
public $time;
public $npcName;
public $drop;
public $level;
public $code;
function getPlayer(){
$db = new dbCon();
$sql = 'SELECT * from player where id = 1';
foreach($db->getCon()->query($sql) as $row ){
$this->name = $row['name'];
$this->time = $row['time'];
$this->npcName = $row['npcName'];
$this->drop = $row['drop'];
$this->level = $row['level'];
$db = null;
}
}
function getLogForm(){
$db = new dbCon();
$sql = 'SELECT * from htmltemplate WHERE id = 1';
foreach($db->getCon()->query($sql) as $row){
$this->code = $row['code'];
}
}
}
Echo in index.php
<?php echo $player->code ?>