Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



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

Posts: 303
Trades: 0
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 :/
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-09-2005, 04:46 AM
mtishetsky's Avatar
King Spam Talker

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

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

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

Posts: 303
Trades: 0
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');
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
Old 06-10-2005, 03:29 AM
mtishetsky's Avatar
King Spam Talker

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

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

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

Posts: 303
Trades: 0
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
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
Old 06-10-2005, 07:37 AM
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.16930 seconds with 12 queries