I am trying to do something like this in a php script but I can't get it to work when I put distinct in there. What am I doing wrong?
If I run it from the command line it works fine.
mysql> select distinct category from products;
If I run it from the command line it works fine.
mysql> select distinct category from products;
Code:
$query = "select distinct category from products";
$result = mysql_query($query);
if ($result)
{
while($row = mysql_fetch_row($result))
{
$name = $row[0];
$desc = $row[1];
$price = $row[2];
$category = $row[3];
echo "Category : $category <br>";
}
}