Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-18-2003, 06:12 PM
fla5h's Avatar
fla5h fla5h is offline
 
Join Date: Dec 2002
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default SORT - ORDER BY , more than one ?

Is it possible in a query to sort by more than one value ?

I wanted to edit the sort by order options in the forumdisplay

so that when I sort by user name it will sort by username but also then sort them into the date of last post.

Is this possible ?

:rambo:
Reply With Quote
  #2  
Old 01-18-2003, 06:31 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ORDER BY username, dateline DESC

the priority is from left to right
Reply With Quote
  #3  
Old 01-18-2003, 07:54 PM
fla5h's Avatar
fla5h fla5h is offline
 
Join Date: Dec 2002
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

nice one Xenon, can you possibly help me further I am have problems doing what I want.

I wanted to make a link on the forum threads ( in the forumdisplay ) so that users can click on them and sort them in set order.

Ie a link next to the thread starters name that when pressed sorts the posts in that thread but also sorts them in the order of lastpost.

So the link I have tried is

/forumdisplay.php?s=&forumid=$forumid&sortfield=pos tusername,%20lastpost&sortorder=asc

It dont work, so I tried this

/forumdisplay.php?s=&forumid=$forumid&sortfield=tes t&sortorder=asc

then in forumdisplay found

PHP Code:
switch ($sortfield) {
  case 
'title':
  case 
'lastpost':
  case 
'replycount':
  case 
'views':
  case 
'postusername':
  case 
'voteavg'
And added

PHP Code:
case 'test'
after it, and found

PHP Code:
if ($sortfield=="voteavg" and !$foruminfo[allowratings]) {
  
$sortfield="lastpost";

and added after it
PHP Code:
if ($sortfield=="test"){
    
$sortfield="postusername, lastpost";
    } 
I get the error

Parse error: parse error, unexpected ',', expecting ']' in C:\Network\Apache2\htdocs\request\forumdisplay.php (702) : eval()'d code on line 1

It dont seem to work even with the error there ?

Can you point me in the direction as to what I need to change ?

Thanks
Reply With Quote
  #4  
Old 01-18-2003, 09:05 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

put
PHP Code:
if ($sortfield=="test"){
    
$sortfield="postusername, lastpost";
    } 
after that:
PHP Code:
$sort = array();
$sort[$sortfield]='selected'
i think you've had it before an that made the problem..
Reply With Quote
  #5  
Old 01-18-2003, 09:06 PM
mr e's Avatar
mr e mr e is offline
 
Join Date: Dec 2001
Posts: 461
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

why dont you try forumdisplay.php?sortfield=username,lastpost&order =asc

then change in the query

PHP Code:
$DB_site->query("SELECT blank FROM blank ORDER by $sortfield $order"
that should work i think
Reply With Quote
  #6  
Old 01-18-2003, 09:11 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

@mr_e: it wouldn work because of this switch case:
PHP Code:
switch ($sortfield) { 
Reply With Quote
  #7  
Old 01-18-2003, 09:37 PM
mr e's Avatar
mr e mr e is offline
 
Join Date: Dec 2001
Posts: 461
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

but then couldn't he eliminate the switch all i thought the switch did was switch it between different querys, so it'd perform one query instead of another...that's what i thought anyway
Reply With Quote
  #8  
Old 01-18-2003, 10:23 PM
fla5h's Avatar
fla5h fla5h is offline
 
Join Date: Dec 2002
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks once again it works fine, one problem I'm getting the following error at the top

Parse error: parse error, unexpected ',', expecting ']' in C:\Network\Apache2\htdocs\request\forumdisplay.php (705) : eval()'d code on line 1

Any ideas ?
Reply With Quote
  #9  
Old 01-19-2003, 04:16 AM
mr e's Avatar
mr e mr e is offline
 
Join Date: Dec 2001
Posts: 461
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

what's line 705 and probably a few lines before and after
Reply With Quote
  #10  
Old 01-19-2003, 08:38 AM
fla5h's Avatar
fla5h fla5h is offline
 
Join Date: Dec 2002
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

line 705 is

PHP Code:
 eval("\$sortarrow[$sortfield] = \"".gettemplate('forumdisplay_sortarrow')."\";"); 
The rest above is unhacked / unaltered.

If i "//" out the eval the error disappears.
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 03:40 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04237 seconds
  • Memory Usage 2,264KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (9)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete