[-_-] Posted November 26, 2007 Share Posted November 26, 2007 How would I make a category field like this? http://thepiratebay.org/browse/200 I want one just for displaying external site links on my main page so people can sort from the site with the highest rating to the lowest rating and sort by what torrents they specialize in. Would I need to use mysql for this? Sorry if thats not the right name for this sort of thing I'm a total noob at php. Quote Link to comment Share on other sites More sharing options...
trq Posted November 26, 2007 Share Posted November 26, 2007 You simply pass the field to sort by through the url, then place that in your query. Something like.... <?php if (isset($_GET['sortby'])) { $sort = $_GET['sortby']; } else { // set a default $sort = 'fld1'; } if (isset($_GET['order'])) { $order = $_GET['order']; } else { $order = 'DESC'; } $sql = "SELECT * FROM tbl ORDER BY $sort $order; ?> Quote Link to comment Share on other sites More sharing options...
[-_-] Posted November 26, 2007 Author Share Posted November 26, 2007 How would I make that viewable? Like piratebay's is? I tried uploading it to my hosting account and got an error. Quote Link to comment Share on other sites More sharing options...
trq Posted November 26, 2007 Share Posted November 26, 2007 Yeah there is an error on the last line, should be.... $sql = "SELECT * FROM tbl ORDER BY $sort $order"; Anyway, this is not complete, working code. Its just an example of how to dynamically create the query required. Sounds like you might need to do some tutorials on database access first. Theres a good link in my signiture which has an entire chapter dedicated to the subject. Quote Link to comment Share on other sites More sharing options...
[-_-] Posted November 26, 2007 Author Share Posted November 26, 2007 Ok thanks. So it has to be done using a database not php alone? I don't need an indexing bot or admin section I was just hoping to open .php files and type in the sites descriptions and how users rate them etc... Quote Link to comment Share on other sites More sharing options...
trq Posted November 26, 2007 Share Posted November 26, 2007 It could be done with flatfiles, but it will be much easier with a database. Quote Link to comment Share on other sites More sharing options...
[-_-] Posted November 26, 2007 Author Share Posted November 26, 2007 Ok thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.