View Full Version : Sorting tables
steven21
07-03-2006, 11:10 PM
Hey Nick,
I am advised that you are the man to speak to about this. for m new site I am wanting to have my tables to be dynamic so that the users can choose how to sort them, whether it be by goals (ascending or descending order), points, etc. currently I just have it so that it is set up so the users can just see the table how I have sorted them in dreamweaver (http://www.myworld21.co.uk/Giants.htm).
can you advise me of a good site that breaks how to do this down in to step by step instructions as I have never done anything like this before and have no idea where to start.
thanks
Nick Irvine
08-03-2006, 09:35 AM
Hey Nick,
I am advised that you are the man to speak to about this. for m new site I am wanting to have my tables to be dynamic so that the users can choose how to sort them, whether it be by goals (ascending or descending order), points, etc. currently I just have it so that it is set up so the users can just see the table how I have sorted them in dreamweaver (http://www.myworld21.co.uk/Giants.htm).
can you advise me of a good site that breaks how to do this down in to step by step instructions as I have never done anything like this before and have no idea where to start.
thanks [/b]
Hi Steven,
I don't think there is a specific site that will help you step by step, no that I know how anyhow.
Essentially what you need is to create a mysql database. You then need a table with the fields: Player, Played, Goals. Assists, Penatly Minutes, Points, Nationality.
The benefits of this is that you can create a password protected admin backend, where every week (or whenever you update it) you can just add on the weeks stats and the table will automatically update.
You will then need to use the following code to sort the tables as the viewers of the site wish. With links to each collum, i.e sort.php?by=player , sort.php?by=played etc Then use the code:
Sorry I cant give you any specific sites but have a search around on google on how to create a mysql database.
If however, you can't find the time to do the work yourself let me know I could do it for you.
steven21
08-03-2006, 10:14 AM
hey Nick,
I really want to try this myself, but at the moment I am a little busier than normal (honest, lol) could you possible do one example for me and then I can take it from there? thats how I learn best (or at least so I think)
cheers mate
I really want to try this myself, but at the moment I am a little busier than normal (honest, lol) could you possible do one example for me and then I can take it from there? thats how I learn best (or at least so I think)
[/b]
Nowt on telly an had a quick look at the forum - glad to see that stupid message is gone - although i'm in the frame of mind the new skin (red borders) looks bloody awful .
Pete being 100% honest as usual :-)
As for your question steven .
If you dont know anything about php - how would you be able to change it if you dont know what anything in the script does ?
.
The effect you want to achive has a big problem , The tabled data on your current website is no use to php as it isnt in a format that is easily understood by php .
In short , To achieve the effect your looking for you would need to prepare the data to suit being read by php & to allow it to be easily sorted by php .
Nick suggests using a mysql database to store the data - that would work great and no problem - but learning how to use mysql/phpmyadmin at the same time as learning php would only really add to the learning curve in this particular case .
I would suggest using a flatfile instead because for somebody at your current skill level there is less things to go wrong .
flatfile = a plain text file with a .txt extension and you can edit them to suit in notepad or whatever text editor you use -
however - stuff like ms word is usually a bad idea because stuff like ms word can sometimes add extra hidden characters when you save the file & thats a bad thing where php is concerned .
I suggest something like textpad or notepad2 when editing plain text files to be used with php .
The following is how the flatfile might look like .....
0
0
0
0
0
14
Theo Fleury
34
21
52
270
73
CAN
0
0
0
0
0
72
Ed Courtenay
42
26
41
119
67
CAN
etc etc
TIP: when creating flatfiles like this its always a good idea to add a few zeros at the start or end of each lump of data for future expansion , While you might not think at this stage you will ever want to add anything else to each lump of data - that would be wrong .
Take my word for it that its a lot easier to edit something in a single line that already exists than adding extra lines later as a afterthought .
Either way the main thing here is you would learn how to read and write to flatfiles and in the process will encounter the usual stumbling blocks when it doesnt work as intended .
php scripting means you usually have to tinker around with something for hours at a time when learning some basic php skills .
Conclusion , People like me/nick/anybody dont mind trying to help if you have a problem and cant get something to work , But me/nick/anybody tend not to write code for other people if they can help it as they have thier own websites and scripts to work on .
If you want something to happen - then i'm afraid its you who will have to put in the work to make it happen .
Heres the deal .....
Have a right good try (at least several hours tinkering around and a damn good try) and when you cant get it to work - then do a cut-n-paste of the php code (and a demo flatfile) and i will rewrite it for you so it works .
BTW: all of this assumes you have php installed on your pc - and if you dont then downloading and installing something like XAMPP that will install AND CONFIGURE php/mysql/apache on your windows pc is a must - as uploading a php file to the webspace everytime you make a small change to becomes very boring very quickly .
NOTE: /xampp/htdocs/stevenswebsite
For the php code to work on your windows pc then you will need to copy your current website folder (wherever it is on your hard disk) to the /xampp/htdocs/ folder .
http://localhost/stevenswebsite
Is what you would use to surf your website offline & your php website will look and work in the exact same way as it does on your webspace .
PHEW! THERES MORE :-)
csn webspace has error messages SUPRESSED and that means if something doesnt work on your webspace then you wont even be given a clue as to what the problem is .
Error supression isnt a bad thing on the webspace though as most people use a offline version of php (i.e. XAMPP) and that doesnt have error messages suppressed .
e.g.
----- demo offline php error message -----
Bad character expecting a T value on line 123
----- demo offline php error message -----
Isnt web authoring a real bummer at times when you practically have to touch your toes to achieve what on the surface appears to be a simple effect LOL :-)
Carl Shepherdson
17-03-2006, 11:47 PM
Nowt on telly an had a quick look at the forum - glad to see that stupid message is gone - although i'm in the frame of mind the new skin (red borders) looks bloody awful .
Pete being 100% honest as usual :-)[/b] The forum message will be restored once an upgrade is available for this version of Invision.
Everyone up to now apart from yourself has liked the forum skin, it is to fit in with our new site design. If you don't like the forum skin im afraid theres nothing that can be done.
Please remember to stay on topic in threads.
Thank you.
Powered by vBulletin™ Version 4.0.3 Copyright © 2010 vBulletin Solutions, Inc. All rights reserved.