Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have simple "SELECT" query on my mysql database table which I execute using php PDO and display the result on a web page.

The results show properly but when I query the statement in phpmyadmin,the order changes according to the query but the order is not affected in the web page generated by php and is always a constant order.

Below is my sample SQL statement:

SQL
SELECT * FROM `mytable` ORDER BY `mytable`.`column1` ASC


column1 is a column containing integer values.

Update:

Following is my sample code:

PHP
//connected to db successfully...
$a=$conn->prepare("SELECT * FROM `mytable` ORDER BY `mytable`.`columns1` ASC")
$a->execute();
while($b=$a->fetch(PDO::FETCH_ASSOC)){
    echo $b['column2'];
    //show results
}


Any help would be highly appreciated.
Thanks in advance.
Posted
Updated 28-Jan-15 9:29am
v4
Comments
Kornfeld Eliyahu Peter 28-Jan-15 14:45pm    
It may help us to help you, if you would show us the relevant code...
Member 11033015 28-Jan-15 15:04pm    
Ok.I will add the code in a moment...
[no name] 28-Jan-15 15:45pm    
And you are sure to see the sort order of 'columns1' in your Output 'column2'....only a question to exclude this doubt.
Member 11033015 28-Jan-15 15:50pm    
"mytable" has multiple columns and in the above example,I'm just displaying one of my table column value as an example.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900