Rows with same id in same div

by Daniel Jensen   Last Updated May 01, 2018 06:10 AM

I have a db-table called vm_kupon. It looks a little like this:

|id  |uid  |bet  |
|1   |20   |1    |
|2   |20   |2    |
|1   |21   |X    |
|2   |21   |1    |
|1   |22   |X    |
|2   |22   |X    |

I would like to show these bets, but I would like it to group the rows with the same uid. Right now I'm doing it like this:

foreach ($results as $row) {
if ($row->uid == 20) 
echo '<div class="kupon">'.$row->bet.'</div>
...
else if ($row->uid == 21)
...

and so on, but isn't there a easier way to just group the rows with same value in a column? I have maybe 20-30 different "groups", so this is a bad way to do it, i think.



Related Questions


Display a Value from a Specific DB Field

Updated April 30, 2016 08:04 AM


Delete users from Joomla V2.5

Updated November 08, 2016 08:04 AM

MySQL Query to show images

Updated May 10, 2017 11:10 AM