group listing

A

Anonymous

Guest
use two queries. One query gets all the groups. then you loop through all the groups and get the dates that are contained in there


psudo code

select all groups
put the groups into array
loop through the array.
while in the loop start a new query to get all the dates within that group.

it's more code. there is prolly a better way to do it tho. :)
 
You could do this with one query. Just ORDER BY the, er, fruit column and the date column, and loop through the results. Each time you encounter a new fruit, print a new header with its name.
 
Code:
$query = 'select * from `groupdates`  order by `group` asc, `date` asc';
        $result = $this->db->query($query);
         $x=0;
          $group = '';
        while($row = mysql_fetch_assoc($result))
        {
          
            if($x==0 || $row['group'] != $group)
            echo '<h5>'.$row['group'].'</h5>';
            echo  $row['date'].'<br />';
            $x++;
            $group = $row['group'];

        }
 
Back
Top