Forums | MacLife
You are not logged in.
#1 2006-03-26 12:47 am
Dreamweaver dynamic links to sort columns?
I have a standard table display from a MySQL database, using Dreamweaver's great dynamic tools. What I'd also like to do is make the column headers a link, so when you click the column header link, it reorders the data based on the column you clicked. So if I had these columns:
Class Instructor Department
and initially, the whole table is sorted by Class, I want to be able to click Instructor and the page would reload with the data now sorted by Instructor.
Does anyone know how to make a link reorder a table ? I know how to do all the stuff like create a recordset, and I'm pretty strong with MySQL, I just can't seem to turn a link into a dynamic link that re-sorts the data.
Thanks
JOhn
Offline
#2 2006-03-27 5:06 am
- W2ttsy
- Member
- Registered: 2002-03-04
- Posts: 3294
Re: Dreamweaver dynamic links to sort columns?
well, in order to create the dynamic pages, youd be using PHP.
my tip, something that ive used before is to use a function and $_GET variable.
what youd want to do is to have a variable that uses the url as a way to push to a way to order the list.
use the following SQL
Code:
"SELECT * FROM tableName ORDER BY $tableName"
then what you want to do in your page is have a variable in the URL that is parsed to the SQL statement.
for instance
Code:
$tableName = $_GET["tableName"];
then have your URLs for each of the links
./pagename.php?tableName=class
./pagename.php?tableName=instructor
./pagename.php?tableName=department
now, when the link is clicked, the page is reloaded with the variable in the URL and that variable is then parsed to the SQL statement.
it is important to remember that the values of tableName in the URL must match the names of each of the columns in your database table.
hope this helps.
W2ttsy
punk!
modding is for rich smurfs, hacking is for pov asses like me
Offline
#3 2006-03-28 12:10 am
- jb
- Member
- From: Melbourne, Australia.
- Registered: 2004-01-04
- Posts: 2179
Re: Dreamweaver dynamic links to sort columns?
W2ttsy wrote:
well, in order to create the dynamic pages, youd be using PHP.
my tip, something that ive used before is to use a function and $_GET variable.
what youd want to do is to have a variable that uses the url as a way to push to a way to order the list.
use the following SQLCode:
"SELECT * FROM tableName ORDER BY $tableName"then what you want to do in your page is have a variable in the URL that is parsed to the SQL statement.
for instanceCode:
$tableName = $_GET["tableName"];then have your URLs for each of the links
./pagename.php?tableName=class
./pagename.php?tableName=instructor
./pagename.php?tableName=department
now, when the link is clicked, the page is reloaded with the variable in the URL and that variable is then parsed to the SQL statement.
it is important to remember that the values of tableName in the URL must match the names of each of the columns in your database table.
hope this helps.
W2ttsy
./pagename.php?tableName=class;INSERT into `admins` ("username", "password", "notes") VALUES ("new_admin", "my_new_password", "Note: I h4x0red you");
Last edited by jb (2006-03-28 12:13 am)
They say that the most secure computer is the one not connected to the internet.
That's why security experts recommend Telstra BigPond.
Offline
#5 2006-03-29 4:02 am
- W2ttsy
- Member
- Registered: 2002-03-04
- Posts: 3294
Re: Dreamweaver dynamic links to sort columns?
"jb wrote:
words...
thanks for turning my nice easy example a lesson in security.
obviously he could guard against an injection attack by parsing the variable thru a filter or similar, but its a bit out of the scope...
W2ttsy
punk!
modding is for rich smurfs, hacking is for pov asses like me
Offline
#6 2006-03-29 4:07 am
- jb
- Member
- From: Melbourne, Australia.
- Registered: 2004-01-04
- Posts: 2179
Re: Dreamweaver dynamic links to sort columns?
Yeah, I know, I just didn't want him to go away with the idea that he was invincible, or something.
Nothing personal, at all. Sorry.
They say that the most secure computer is the one not connected to the internet.
That's why security experts recommend Telstra BigPond.
Offline
#8 2006-03-29 1:44 pm
Re: Dreamweaver dynamic links to sort columns?
jb wrote:
W2ttsy wrote:
well, in order to create the dynamic pages, youd be using PHP.
my tip, something that ive used before is to use a function and $_GET variable.
what youd want to do is to have a variable that uses the url as a way to push to a way to order the list.
use the following SQLCode:
"SELECT * FROM tableName ORDER BY $tableName"then what you want to do in your page is have a variable in the URL that is parsed to the SQL statement.
for instanceCode:
$tableName = $_GET["tableName"];then have your URLs for each of the links
./pagename.php?tableName=class
./pagename.php?tableName=instructor
./pagename.php?tableName=department
now, when the link is clicked, the page is reloaded with the variable in the URL and that variable is then parsed to the SQL statement.
it is important to remember that the values of tableName in the URL must match the names of each of the columns in your database table.
hope this helps.
W2ttsy./pagename.php?tableName=class;INSERT into `admins` ("username", "password", "notes") VALUES ("new_admin", "my_new_password", "Note: I h4x0red you");
You rock!
Offline
#9 2006-03-29 1:52 pm
- jb
- Member
- From: Melbourne, Australia.
- Registered: 2004-01-04
- Posts: 2179
Re: Dreamweaver dynamic links to sort columns?
Why? 
They say that the most secure computer is the one not connected to the internet.
That's why security experts recommend Telstra BigPond.
Offline
#11 2006-03-29 10:46 pm
- W2ttsy
- Member
- Registered: 2002-03-04
- Posts: 3294
Re: Dreamweaver dynamic links to sort columns?
it was posted late at night. yes there were security flaws or something similar, but the ideas were there...
W2ttsy
punk!
modding is for rich smurfs, hacking is for pov asses like me
Offline
#12 2006-03-30 3:40 am
- jb
- Member
- From: Melbourne, Australia.
- Registered: 2004-01-04
- Posts: 2179
Re: Dreamweaver dynamic links to sort columns?
W2ttsy - relax. It wasn't anything personal, and your post was very helpful.
They say that the most secure computer is the one not connected to the internet.
That's why security experts recommend Telstra BigPond.
Offline



