Hello Everyone
I was hoping someone may be able to help me solve a problem i have.
well at present i have this bit of code below:
$DLmq = "SELECT * FROM distance_learn_operations, prog_dis_learn, programme WHERE distance_learn_operations.short_code=prog_dis_learn.short_code
AND prog_dis_learn.prog_id=programme.prog_id";
if ($prog_title <> "") {
$DLmq .= " AND programme.prog_title = '" . $prog_title . "'
GROUP BY distance_learn_operations.centre_name";
}
if ($DLName <> "") {
$DLmq .= " AND distance_learn_operations.centre_name = '" . $DLName . "'
GROUP BY distance_learn_operations.centre_name";
}
if ($DLCountry <> "") {
$DLmq .= " AND distance_learn_operations.country = '" . $DLCountry . "'
GROUP BY distance_learn_operations.centre_name";
}
echo ("SQL=" . $DLmq . "<br>");
$result = mysql_query($DLmq, $db);
While ($rec = mysql_fetch_array($result)) {
echo("<tr>");
echo("<td><div align=\"center\">" . $rec["centre_name"] . "<br>\n</div></td>");
echo("<td><div align=\"center\">" . $rec["country"] . "<br>\n</div></td>");
echo("<td><div align=\"center\">" . $rec["prog_title"] . "<br>\n</div></td>");
echo("</tr>");
}
Its a search form allowing users to search via any field
My problem is say a centre runs 5 different programmes, the output i wud like is for the centre name and country to appear once and then for the 5 different programmes to be listed next to them
But i wasnt getting this im getting the centre name and country appearing 5 different times also
As you can see in my code ive tried to group by centre name, but now im only getting one row of results
eg. centre name, country and only 1 programme
even thou i know that the centre runs 5 different programmes.
The main thing is a centre can run 1 - many programmes, so need a way of showing them all but only showing the centre name and country once.
any help on how i wud change my code to implement this would be greatly appreicated
thanks in advance
snoopgreen