Question

how do i put list in while loop?

PHP:

> $q = $db->query("SELECT * FROM
> bs_events LEFT JOIN bs_reservations ON
> bs_reservations.id_event = bs_events.id   
> GROUP BY bs_reservations.id_event 
> ORDER BY bs_events.eventDate ASC LIMIT 20");

HTML TABLE:

> while($r = $q->fetch_array(MYSQLI_ASSOC)):  
> echo '<tr>';
> echo '<td>' . $r['title'] . '</td>';  
> echo '<td>' . date('d/M/Y', strtotime($r['eventDate'])) . ' / ' . $r['eventTime'] . '</td>';  
> echo '<td>' . $r['location'] . '</td>';  
> echo '<td>' . array($r['username']) .'</td>';  
> echo '<td ></td>';  
> echo '<td ></td>';  
> echo '</tr>';  
> endwhile;

the above code will output

TITLE        DATE/TIME      LOCATION    USERNAME
=================================================
1       dd/mm/yyy / hh:mm   location    username
1       dd/mm/yyy / hh:mm   location    username1 
1       dd/mm/yyy / hh:mm   location    username2 
2       dd/mm/yyy / hh:mm   location    username   

and i want the output

TITLE        DATE/TIME      LOCATION    USERNAME
=================================================
1       dd/mm/yyy / hh:mm   location    username, username1, username2  
2       dd/mm/yyy / hh:mm   location    username 

or do i need to put foreach on echo '<td>' . array($r['username']) .'</td>';

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top