Reply
Sorting database Information.
Old 06-09-2005, 12:46 AM Sorting database Information.
lothop's Avatar
Extreme Talker

Posts: 229
Hiya, I'm trying to sort a database from what a user clicks on. So if they click on "sortbyname" it sorts it by name, and if they click on "sortbydate" it sorts the information by date.

This is what I have so far :
The link clicked on takes them to http://localhost/list.invoice.php?page=date

Then,

PHP Code:
<?php 
echo $WFunctions->listInvoices($_GET['page']);
?>
This pulls what page equals, so for this example its "date"

PHP Code:
function listInvoices($page) { 
Then this gets it.

PHP Code:
$query mysql_query("SELECT * FROM invoice WHERE filename = '".$element."' ORDER BY $page"); 
And this trys to sort it.


The information is getting sent because I can use
PHP Code:
echo('$user_id'); 
And it prints out what page equals.

It doesn;t sort the data though
Really stuck here :/
__________________
CUrrent sites working on...

http://www.Crashdays.com/
http://www.nzfiles.com/
lothop is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 06-09-2005, 03:46 AM
mtishetsky's Avatar
King Spam Talker

Posts: 1,061
Name: Mike
Location: Mataro, Spain
print() what is the $page value right before calling this:
$query = mysql_query("SELECT * FROM invoice WHERE filename = '".$element."' ORDER BY $page");
__________________
Free Mobile Phone Themes

And don't forget to give me talkupation!
mtishetsky is online now
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 06-10-2005, 01:34 AM
lothop's Avatar
Extreme Talker

Posts: 229
What ever index.php?page='s

So, if its index.php?page=date, it sorts by date
if its index.php?page=name, it sorts by name

But it isnt sorting. or ordering.

SORRY! echo('$user_id'); should be echo('$page');
__________________
CUrrent sites working on...

http://www.Crashdays.com/
http://www.nzfiles.com/
lothop is offline
Reply With Quote
View Public Profile
 
Old 06-10-2005, 02:29 AM
mtishetsky's Avatar
King Spam Talker

Posts: 1,061
Name: Mike
Location: Mataro, Spain
I don't understand waht do you want to get. What do you think the 'sorting' is and how does it differ from 'ordering'?
__________________
Free Mobile Phone Themes

And don't forget to give me talkupation!
mtishetsky is online now
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 06-10-2005, 05:48 AM
lothop's Avatar
Extreme Talker

Posts: 229
ORDER BY

Orders the database information pull. correct?

I want the user to be able to sort the list how ever the wish.

Eg. List A-Z with name
List A-Z, 1-9 with Date
__________________
CUrrent sites working on...

http://www.Crashdays.com/
http://www.nzfiles.com/
lothop is offline
Reply With Quote
View Public Profile
 
Old 06-10-2005, 06:37 AM
mtishetsky's Avatar
King Spam Talker

Posts: 1,061
Name: Mike
Location: Mataro, Spain
So add one more parameter to your request and also enhance your sql query, something like that:
select * from invoice where filename = '$element' and lalala regexp '[A-z1-9]' order by $page
I thought it is obvious.
__________________
Free Mobile Phone Themes

And don't forget to give me talkupation!
mtishetsky is online now
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to Sorting database Information.
 

Thread Tools

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13260 seconds with 12 queries