a little more help with PHP/MySQL

Alrite, I've been working on another one of my websites and the coding for the main php script is goin fine. But now I'm wondering how to do something else with mysql. I have it so that when a person goes to the page i've created, tag.php?where=foo , the word that is put in the where variable (foo for this example) is first added to the database, but if an instance of it is found then it counts the number of times it has gone up, for example:
---------------------------------
|Where | Times |
---------------------------------
|Foo | 1 |
---------------------------------
|foobar | 5 |
---------------------------------
|Bologna | 7 |
---------------------------------
So this is more or less what the table looks like. The times column is the number of times that someone has gone to a link with the ?where= being the word in the where column get it? So now, on to the actual question part of the post. How do i make it so that I have, on my main index page, a list of the top five most used words in order of the most popular, so on the main page I would have:
The most used words:
1. Bologna: 7 times
2. foobar: 5 times
3. Foo: 1 times
But it would only show the top five and they would be in order from highest to lowest as above. Any help? (and can you even understand what im asking..)Oh, and by the way..this it what i have for coding:

if ($_GET["where"] != "") {
$bodypart = $_GET["where"];
$db = mysql_connect("localhost", "bouley86", "****");
mysql_select_db("test",$db);
$select = mysql_query("select * from tag where bodypart = '{$_GET["where"]}'");
if(mysql_num_rows($select)){
$row = mysql_fetch_array($select);
$times = $row["times"];
$times++;
$sql = "UPDATE tag SET times = '$times' WHERE bodypart = '{$_GET["where"]}'";
$result = mysql_query($sql);
} else {
$insert = mysql_query("INSERT INTO tag (bodypart,times)
VALUES ('$bodypart','1')");
}well..i answered my own question..thank me for my help..you're welcome :) (if anyone else would like to know how to do this, email me!)....*sigh*
 
Back
Top