My sql query outputs this:
but I want only one heading for each language like this:
So I thought I'd check if the heading is already in the array, if not then add it to the array and print it. If it's already there return "".
And the sql:
But it doesn't work and outputs duplicate headings. Does anyone know why or can suggest and alternate way of doing this? Thanks in advance...
Code:
Afrikaans
MATTHEWS,Hilda
Tel: 020-7284-4774 ,Mob: 07956-442586
Arabic
KUZI-SARIG,Sari
Tel: 020-8954-5354 ,Mob: 07956-387835 ,Fax: 020-8954-5354
Bulgarian
BALDWIN,Milva
Tel: 020-8882-9861 ,Mob: 07989-555151 ,Fax: 00-33-1-48080049
Bulgarian
COLLINS,Dolly
Tel: 0033472399383 ,Mob: 003310680149344 ,Fax: 0022478562945
Cantonese
HAUCHU,Tim
Tel: 020-8653-3070 ,Fax: 020-8653-3070
Cantonese
LOK,Suky
Tel: 020-8505-8088 ,Mob: 07710-235-095 ,Fax: 020-8505-8088
Code:
Afrikaans
MATTHEWS,Hilda
Tel: 020-7284-4774 ,Mob: 07956-442586
Arabic
KUZI-SARIG,Sari
Tel: 020-8954-5354 ,Mob: 07956-387835 ,Fax: 020-8954-5354
Bulgarian
BALDWIN,Milva
Tel: 020-8882-9861 ,Mob: 07989-555151 ,Fax: 00-33-1-48080049
COLLINS,Dolly
Tel: 0033472399383 ,Mob: 003310680149344 ,Fax: 0022478562945
Cantonese
HAUCHU,Tim
Tel: 020-8653-3070 ,Fax: 020-8653-3070
LOK,Suky
Tel: 020-8505-8088 ,Mob: 07710-235-095 ,Fax: 020-8505-8088
Code:
$old_value = array();
function newValue($value1){
if (in_array($value1,$old_value)){
return "";
}else{
array_push($old_value,$value1);
return $value1;
}
}
Code:
$qMain = "SELECT * FROM my_table";
$result = mysql_query($qMain) or die (mysql_error());
$num = mysql_num_rows($result);
$i=0;
while($i < $num){
$guide_surname = mysql_result($result,$i,"guide_surname");
$guide_forename = mysql_result($result,$i,"guide_forename");
$code_abbreviation = mysql_result($result,$i,"code_description");
$telephone_type = mysql_result($result,$i,"telephone_type");
echo newValue($code_abbreviation)."<br>$guide_surname,$guide_forename<br>$Tel $Mob $Fax $Pgr<br>";
++$i;
}