I am having problems displaying the data, the page is loading fine with no error and the thead of the table is loading but its not showing any data and cannot see whats wrong. Second pair of eyes maybe needed here?
<?php
// Include config file
include('../config.php');
// Database Connection
try {
$db = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8', DB_USER, DB_PASSWORD);
}
catch(PDOException $e) {
die("Could not connect to the database
");
}
// Get Raffle list
function get_raffle_list(){
global $db;
echo '
<table class="table table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Started</th>
<th>Duration (days)</th>
<th>End Date</th>
<th>Ticket Price</th>
<th>Percentage of Winners</th>
<th>Tickets Purchased </th>
<th>Total Amount</th>
<th>Available to be Won (%)</th>
<th>Available to be Won ($)</th>
<th>Options</th>
<th>Finish Raffle </th>
</tr>
</thead>';
$stmt = $db->prepare("SELECT id, started, duration, ticket_price, win_percentage, available
FROM " . $db_prefix . "lotteries WHERE ended = '0' ORDER BY started DESC");
$stmt->execute();
echo "<tbody>";
// loop through all result rows
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo '<tr>
<td>'. $row['id'] .'</td>
<td>'. date("m-d-Y", $row['started']) .'</td>
<td><?php echo $duration; ?></td>
<td>'. date("m-d-Y", $row['started'] + $row['duration']*3600*24) .'</td>
<td>'. $row['ticket_price'] .'</td>
<td>'. $row['win_percentage'] .'</td>
<td>'. $row['tickets_qty'] .'</td>
<td>'. ($row['ticket_price'] * $row['tickets_qty']) .'</td>
<td>'. $row['available'] .'</td>
<td>'. (floor($row['ticket_price'] * $row['tickets_qty'] * $row['available']) / 100) .'</td>
<td><a href="flvby.php?go=dellottery&id='. $row['id'] .'">Delete</a></td>
<td><a href="flvby.php?go=randlottery&id='. $row['id'] .'">Randomly</a></td>
<td><a href="flvby.php?go=manlottery&id='. $row['id'] .'">Manually</a></td>
</tr>';
}
echo '<tbody></table>';
}
?>