Jump to content

[SOLVED] help with ORDER BY


rsammy

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/36534-solved-help-with-order-by/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.