![]() |
|
#1
|
|||
|
|||
Sorting information in a databaseHello,
I will appoligise up front if this is a dumb question. But, I am learning PHP as I create my website, so I am not learning it in any type of structured order. I want to display links on my website according to popularity. (Top ten) but, I am not sure how to accomplish this, and what is the best way to do this. 1) Sort and store the results in a seperate database. 2) Have it sort dynamically as the page is loaded. 3) Is there a way to do this with out another database? 4) How to set this up to update on a weekly basis? Thanks, Richard |
|||
|
#2
|
|||
|
|||
Re: Sorting information in a databaseIf your database is set to store both a url and rating for each link, you could use a statement like the one below.
SELECT url, rating FROM mytable ORDER BY rating DESCENDING; Note, however, that you still have to up the rating in order for this to work. That could always be done by the link being something like... <a href="up_rate.php?url=$url">$url</a> and on up_rate.php, run a query that increases the rating... SELECT rating FROM mytable WHERE url = '$url'; (increase rating by 1) UPDATE TABLE mytable SET rating = '$newrating'; and then redirect to $url. There very well may be a simpler way to do this, but above is how I know to do it. |
|
#3
|
||||
|
||||
Re: Sorting information in a databaseI remember a post submitted by Allowee quite a while ago that you may find interesting: http://www.gidforums.com/t-1194.html. At least it will point you in a direction to get the link markups done.
For you to sort a set of results, you need to maintain a column of data in your database table on which you will apply the sort. It's really quite uncomplicated but I think I can help you better if you describe the table and post some sample data in your reply. __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
Recent GIDBlog
Programming ebook direct download available by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help with Classes and database arrays | brookeville | C++ Forum | 1 | 13-Apr-2005 01:26 |
| Limit combo box and date time picker choice according to database created in folder | shinyhui | C++ Forum | 0 | 22-Feb-2005 21:16 |
| Limit combo box and date time picker choice according to database created in folder | shinyhui | MS Visual C++ / MFC Forum | 0 | 22-Feb-2005 03:13 |
| Computer privacy article | crystalattice | Open Discussion Forum | 0 | 01-Oct-2004 15:26 |
| cgi txt database to mysql | erhanharputlu | MySQL / PHP Forum | 0 | 27-Sep-2004 02:30 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The