更新时间:2023-02-26 09:54:44
$ q = $ db-> query(SELECT * FROM bs_events
LEFT JOIN bs_reservations ON bs_reservations.id_event = bs_events.id);
$ b $ while($ r = $ q-> fetch_array(MYSQLI_ASSOC)):
foreach($ r as $ value){
echo'< td>'。 $值。 < / TD>;
}
endwhile;
应该为每个表行回显每列值。
编辑:如果您只想要与会者:
$ q = $ db-> query(SELECT * FROM bs_events
LEFT JOIN bs_reservations ON bs_reservations.id_event = bs_events.id);
$ b $ while($ r = $ q-> fetch_array(MYSQLI_ASSOC)):
for($ i = 1; $ i echo' < td>'。 $ r ['attendee'。$ i]。 < / TD>;
}
endwhile;
ive got 1 database table contains row:
TABLE FROM reservations:
attandee01
attandee02
attandee03
attandee04
attandee05
attandee06
PHP CODE:
$q = $db->query("SELECT * FROM bs_events
LEFT JOIN bs_reservations ON bs_reservations.id_event = bs_events.id");
while($r = $q->fetch_array(MYSQLI_ASSOC)):
echo '<td>' . $r['attandee1'] . '</td>';
echo '<td>' . $r['attandee2'] . '</td>'
echo '<td>' . $r['attandee3'] . '</td>'
endwhile;
or is there any simple way using foreach to echo attandee1 - attandee10?
$q = $db->query("SELECT * FROM bs_events
LEFT JOIN bs_reservations ON bs_reservations.id_event = bs_events.id");
while($r = $q->fetch_array(MYSQLI_ASSOC)):
foreach($r as $value) {
echo '<td>' . $value . '</td>';
}
endwhile;
Should echo each column value per table row.
EDIT: If you only want the attendees:
$q = $db->query("SELECT * FROM bs_events
LEFT JOIN bs_reservations ON bs_reservations.id_event = bs_events.id");
while($r = $q->fetch_array(MYSQLI_ASSOC)):
for($i = 1; $i < 11 $i++) {
echo '<td>' . $r['attendee'.$i] . '</td>';
}
endwhile;