vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   SORT - ORDER BY , more than one ? (https://vborg.vbsupport.ru/showthread.php?t=47842)

fla5h 01-18-2003 06:12 PM

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:

Xenon 01-18-2003 06:31 PM

ORDER BY username, dateline DESC

the priority is from left to right :)

fla5h 01-18-2003 07:54 PM

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 :)

Xenon 01-18-2003 09:05 PM

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..

mr e 01-18-2003 09:06 PM

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

Xenon 01-18-2003 09:11 PM

@mr_e: it wouldn work because of this switch case:
PHP Code:

switch ($sortfield) { 


mr e 01-18-2003 09:37 PM

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

fla5h 01-18-2003 10:23 PM

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 ?

mr e 01-19-2003 04:16 AM

what's line 705 and probably a few lines before and after

fla5h 01-19-2003 08:38 AM

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.


All times are GMT. The time now is 12:15 AM.

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.00997 seconds
  • Memory Usage 1,742KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (9)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete