I would alter your query a bit:
$sql="
SELECT entry_id,programme_name,DATE_FORMAT(programme_date,'%D %M %Y') as 'datey', prog_name,prog_id
FROM calendar,programmes
WHERE calendar.programme_month = '$today'
AND calendar.programme_name = programmes.prog_name
ORDER BY prog_id ASC, programme_date ASC
";
then i would loop through the results, only creating a new output string every time the entry_id changes....something like
$prev_id = '';
$data_ary = array();
$i = -1;
while($row = mysql_fetch_array($result) {
if ($row['prog_id'] != $prev_id) {
$i++;
$data_ary[$i] = array();
$data_ary[$i]['id'] = $row['prog_id'];
$data_ary[$i]['name'] = $row['programme_name'];
$data_ary[$i]['dates'] = array();
}
$data_ary[$i]['dates'][] = $row['datey'];
$prev_id = $row['prog_id'];
}
then you can loop thru the array you've built and output stuff like this:
foreach($data_ary as $key=>$row) {
echo 'id:' . $row['id'] . '<br>';
echo 'name:' . $row['name'] . '<br>';
echo 'dates:' . implode(',', $row['dates']);
}
or something like that...i haven't tested it but you should get the idea.
EDIT: I had to edit this a few times for typos...