I want to make a voting list kind of thing. I have a form that saves the entered data to mysql database. Suppose a user entered "Something". It'll be saved in column called "bname". Now what I want is Suppose 10 people entered "Something" or "something"(case sensitivity to be ignored automatically if there is a way?) then I want: "Something - 10" to be printed in php page.
My try:
$query="SELECT bname, count
FROM brandnames
GROUP BY bname
HAVING COUNT(*) > 0
LIMIT 11";
$result=mysqli_query($con,$query) or die('Error!: ' . mysqli_error($con));
$query2="SELECT count
FROM brandnames
GROUP BY count
HAVING COUNT(*) > 0
ORDER BY count DESC
LIMIT 11";
$result2=mysqli_query($con,$query2) or die('Counting Error!: ' . mysqli_error($con));
while ($row=mysqli_fetch_assoc($result))
{
while ($row2=mysqli_fetch_assoc($result2))
{
echo ($row['bname'] . ' ' . '-' . ' ' . $row2['count'] . '<br />');
}
}
This thing prints Something - 4 Something - 3
I do not want to use this method. I posted this as if I don't post someone will point me out to post. :/
I don't want to use "count" column. I want a simple voting list as I mentioned above.
Thanks, :)