我在显示数据时遇到问题,页面加载正常,没有错误,并且表格的标题正在加载,但它没有显示任何数据并且看不到有什么问题。这里可能需要第二双眼睛?
<?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\n");
}
// 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>';
}
?>