Hiya All,
Not sure if i should be putting thi up on the SQL section but i think the problem lies in the PHP part of my code.
This is what i've got. I'm counting the number of times a category shows up in my database returning the name of that category with the count next to it.
I'm printing the first 5 results individually then putting the rest into a dropdown box (order by count)
My problem is there is a category missing (schools__30) which would be the 6th result in line i.e. the first to appear in the dropdow box.
The code is below any help much appreciated,
$i=1;
$sql = "SELECT Company.Classification, COUNT(DISTINCT Company.Name) as 'Number'
FROM Company WHERE Company.Classification<>'' GROUP BY Company.Classification ORDER BY Number DESC";
$result = mysql_query($sql);
while(($nt=mysql_fetch_array($result))&&($i<=5))
{
echo "<a href='http://www." . $nt['Classification'] . ".html' target='_blank'>" . $nt[Classification] . "____" . $nt
[Number] . "</a><br /> ";
$i++;
}
echo "<select onchange='window.location.href=this.options[this.selectedIndex].value'>";
while($nt=mysql_fetch_array($result))
{
echo "<option value='http://www." . $nt[Classification] . ".html'>" . $nt[Classification] . "____" . $nt[Number] . "</option> ";
}
echo "</select>";