AUCKLANDIT
asked on
Limit Result to one occurance of a name MYSQL PHP
Hello,
I need to select some calling rates to display on another website all works well but the issue I have is that there are many duplicates in the database due to there being a number of dial prefixes, all I want to show how ever it the destination (Country Name) and the Sell Pirce per minute.
Code attached that works.... to show all
So result at the moment is displayed for example;
Afghanistan 0.25000
Afghanistan 0.25000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Albania 0.05000
Albania 0.05000
Albania Mobile 0.35000
Albania Mobile 0.35000
Albania Mobile 0.35000
Albania Mobile 0.35000
Albania Mobile 0.35000
Albania Mobile 0.35000
but I want it to disaply like this,
Afghanistan 0.25000
Afghanistan Mobile 0.28000
Albania 0.05000
Albania Mobile 0.35000
How can I do this?
I need to select some calling rates to display on another website all works well but the issue I have is that there are many duplicates in the database due to there being a number of dial prefixes, all I want to show how ever it the destination (Country Name) and the Sell Pirce per minute.
Code attached that works.... to show all
So result at the moment is displayed for example;
Afghanistan 0.25000
Afghanistan 0.25000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Afghanistan Mobile 0.28000
Albania 0.05000
Albania 0.05000
Albania Mobile 0.35000
Albania Mobile 0.35000
Albania Mobile 0.35000
Albania Mobile 0.35000
Albania Mobile 0.35000
Albania Mobile 0.35000
but I want it to disaply like this,
Afghanistan 0.25000
Afghanistan Mobile 0.28000
Albania 0.05000
Albania Mobile 0.35000
How can I do this?
<?php
$dbhost = 'host';
$dbuser = 'user';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'database';
mysql_select_db($dbname);
$sql = 'SELECT cc_prefix.destination, cc_ratecard.rateinitial FROM cc_ratecard, cc_prefix WHERE cc_ratecard.destination = cc_prefix.prefix ORDER BY cc_prefix.destination ASC';
$result = mysql_query ($sql) or die ('Cannot Select Error : ' . mysql_error());
while($row = mysql_fetch_array($result)) {
echo $row['destination'];
echo " ";
echo $row['rateinitial'];
echo "<br />";
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
this should do:
$sql = 'SELECT cc_prefix.destination, cc_ratecard.rateinitial FROM cc_ratecard, cc_prefix WHERE cc_ratecard.destination = cc_prefix.prefix GROUP BY cc_prefix.destination ORDER BY cc_prefix.destination ASC';
$sql = 'SELECT cc_prefix.destination, cc_ratecard.rateinitial FROM cc_ratecard, cc_prefix WHERE cc_ratecard.destination = cc_prefix.prefix GROUP BY cc_prefix.destination ORDER BY cc_prefix.destination ASC';
ASKER