rsammy Posted January 31, 2007 Share Posted January 31, 2007 this is my query... $query2="SELECT batch_ID, batch_date_created, batch_time_created FROM billing_batch WHERE batch_date_created <= '$dates' AND batch_date_created >= '$datez' ORDER BY batch_ID, '$select'"; $select above is either ascending or descending on the screen based on option chosen from drop down box. i know the query is not corect at the ORDER BY point. how do i make it sort it accroding to option selected for '$select' ??? right now, it just displays ascending whatever i choose becos the syntax is wrong. HELP PLEASE.... Quote Link to comment https://forums.phpfreaks.com/topic/36534-solved-help-with-order-by/ Share on other sites More sharing options...
Psycho Posted January 31, 2007 Share Posted January 31, 2007 Well, what are the exact values in the select field? if they are not ASC or DESC you will need to convert the values to those first. Also, are you sending the value through GET or POST? Quote Link to comment https://forums.phpfreaks.com/topic/36534-solved-help-with-order-by/#findComment-173962 Share on other sites More sharing options...
pikemsu28 Posted January 31, 2007 Share Posted January 31, 2007 if this is you querry and $select value is either desc or asc, your ORDER BY part has a comma that is erroring out your query ORDER BY batch_ID, '$select'"; should be ORDER BY batch_ID '$select'"; Quote Link to comment https://forums.phpfreaks.com/topic/36534-solved-help-with-order-by/#findComment-173966 Share on other sites More sharing options...
rsammy Posted January 31, 2007 Author Share Posted January 31, 2007 if it put a ',' there, it does not show me in the order selected(shows ascending by default). but if remove the ',' it shows an error on screen! Quote Link to comment https://forums.phpfreaks.com/topic/36534-solved-help-with-order-by/#findComment-174046 Share on other sites More sharing options...
Psycho Posted February 1, 2007 Share Posted February 1, 2007 Again, back to my questions: Well, what are the exact values in the select field? if they are not ASC or DESC you will need to convert the values to those first. Also, are you sending the value through GET or POST? Are you populating the value of $select from the POST or GET object? Have you verified that the value is what you expected to be? if it put a ',' there, it does not show me in the order selected(shows ascending by default). but if remove the ',' it shows an error on screen! What error are you getting. We don't have crystal balls. Quote Link to comment https://forums.phpfreaks.com/topic/36534-solved-help-with-order-by/#findComment-174108 Share on other sites More sharing options...
HuggieBear Posted February 1, 2007 Share Posted February 1, 2007 We don't have crystal balls. How do you know what my balls look like Huggie Quote Link to comment https://forums.phpfreaks.com/topic/36534-solved-help-with-order-by/#findComment-174111 Share on other sites More sharing options...
rsammy Posted February 1, 2007 Author Share Posted February 1, 2007 nevermind. thanx all for replying. i figured it out! problem solved. Quote Link to comment https://forums.phpfreaks.com/topic/36534-solved-help-with-order-by/#findComment-174121 Share on other sites More sharing options...
Psycho Posted February 1, 2007 Share Posted February 1, 2007 And for others that may be looking for a solution to a similar problem, the solution was . . . ? Quote Link to comment https://forums.phpfreaks.com/topic/36534-solved-help-with-order-by/#findComment-174135 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.