问题描述
我的mysql数据库表上有简单的SELECT查询,我使用php PDO执行并在网页上显示结果。
结果显示正确但是当我在phpmyadmin中查询语句时,顺序会根据查询而变化,但顺序不会受到php生成的网页的影响,并且始终是一个固定的顺序。
下面是我的示例SQL语句:
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:
SELECT * FROM `mytable` ORDER BY `mytable`.`column1` ASC
column1是一个包含整数值的列。
更新:
以下是我的示例代码:
column1 is a column containing integer values.
Update:
Following is my sample code:
//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.
推荐答案
这篇关于SQL ORDER BY在phpmyadmin中工作但不在PHP网页中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!