I’m using PHP to generate the html for a table. The problem is that if there are n+1 rows generated on the table the code is generating n empty table row tags, all of them appearing prior to the rows made from the database info.
[php]
function getGameTable(){
$table ="";
$query = “SELECT player1, player2, winner, points, league, date, location FROM games”;
if($stmt = $this->connect->prepare($query)){
$stmt->execute();
$stmt->bind_result($player1, $player2, $winner, $points, $league, $date, $location);
$table = “”;
while($stmt->fetch()){
$table = $table. “
“
“
“
“
“
$table = “
}
}
$stmt->close();
return $table;
}
[/php]
if there were 2 database rows the webpage output here looks like this minus my comment:
[php]
So if there were 100 database rows i end up with 99