0

I have this mySQL Query

SELECT list.*, brand.displayed_text AS brandName
FROM itemmaster_list AS list
LEFT JOIN brand_lists AS brand ON brand.cid = list.brandcode
WHERE brandcode = 'abc'
ORDER BY list.orderpriority DESC, list.date_added DESC , list.cid DESC

When you run this in PHPMySQL it returns data CORRECTLY sorted by the field [list.orderpriority]

but when you run it in my php code (thru browser) it sorts data by the field [list.date_added]

PHP Code

$result_item = mysql_query("SELECT list.*, brand.displayed_text AS brandName FROM itemmaster_list 
AS list LEFT JOIN brand_lists AS brand ON brand.cid = list.brandcode WHERE brandcode = 'abc' 
ORDER BY list.orderpriority DESC, list.date_added DESC , list.cid DESC") or die(mysql_error());

if (mysql_num_rows($result_item) > 0) {
    while($row_item = mysql_fetch_array($result_item)) {
        [echo here the records]
    }
}
4

1 回答 1

0

问题解决了。

事实证明,我们的主机在没有告诉我们的情况下将我们转移到新服务器,所以我们有两个数据库,PHP 文件连接到新数据库,而我正在使用的 phpMySQL 是旧数据库,这就是我得到不同结果的原因。

于 2012-07-28T18:31:23.410 回答