Jump to content

Display data by alphabetical order


RON_ron

Recommended Posts

I want to pull the mysql data in an alphabetical order suburbz. This code is not getting the results in an alphabetical order. Please help.

 

$SomeVar = $_POST['disloc'];
$query = "SELECT * FROM  books WHERE statez = '".$SomeVar."' ORDER BY suburbz ASC";
$results = mysql_query($query);

Link to comment
https://forums.phpfreaks.com/topic/213356-display-data-by-alphabetical-order/
Share on other sites

I want to pull the mysql data in an alphabetical order suburbz. This code is not getting the results in an alphabetical order. Please help.

 

$SomeVar = $_POST['disloc'];
$query = "SELECT * FROM  books WHERE statez = '".$SomeVar."' ORDER BY suburbz ASC";
$results = mysql_query($query);

 

Use mysql_error() to get a description of the problem. It's most likely either the table or a field name is wrong or the data that is being posted contains bad chars and is causing the query to break due to not escaping the string before putting it in the query.

Can you tell me what you get in $_POST['disloc']?

 

No data found then problem with your input.

 

Please try query without WHERE, if you get correct output what you expect then you have problem with inputs.

 

$query = "SELECT * FROM  books ORDER BY suburbz ASC";
$results = mysql_query($query);

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.