GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 21-Nov-2006, 08:44
Richardknox Richardknox is offline
Junior Member
 
Join Date: Nov 2006
Location: Michigan
Posts: 83
Richardknox is on a distinguished road

Sorting information in a database


Hello,

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  
Old 30-Nov-2006, 15:49
trickhat trickhat is offline
New Member
 
Join Date: Nov 2006
Posts: 7
trickhat is on a distinguished road

Re: Sorting information in a database


If 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  
Old 30-Nov-2006, 19:52
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

Re: Sorting information in a database


I 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.
 
 

Recent GIDBlogToyota - 2008 July Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Classes and database arrays brookeville CPP / C++ Forum 1 13-Apr-2005 00:26
Limit combo box and date time picker choice according to database created in folder shinyhui CPP / C++ Forum 0 22-Feb-2005 20: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 02:13
Computer privacy article crystalattice Open Discussion Forum 0 01-Oct-2004 14:26
cgi txt database to mysql erhanharputlu MySQL / PHP Forum 0 27-Sep-2004 01:30

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:29.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.