-1

我有以下一段 PHP

$manufacturers_query_raw = "select manufacturers_id, manufacturers_name, manufacturers_image, date_added, last_modified from " . TABLE_MANUFACTURERS . " order by manufacturers_name";
$manufacturers_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS_ADMIN, $manufacturers_query_raw, $manufacturers_query_numrows);
$manufacturers_query = tep_db_query($manufacturers_query_raw);
while ($manufacturers = tep_db_fetch_array($manufacturers_query)) 
{
 if ((!isset($HTTP_GET_VARS['mID']) || (isset($HTTP_GET_VARS['mID']) && ($HTTP_GET_VARS['mID'] == $manufacturers['manufacturers_id']))) && !isset($mInfo) && (substr($action, 0, 3) != 'new')) {
  $manufacturer_products_query = tep_db_query("select count(*) as products_count from " . TABLE_PRODUCTS . " where manufacturers_id = '" . (int)$manufacturers['manufacturers_id'] . "'");
  $manufacturer_products = tep_db_fetch_array($manufacturer_products_query);
  $mInfo_array = array_merge($manufacturers, $manufacturer_products);
  $mInfo = new objectInfo($mInfo_array);
}

我在网页上收到以下错误:

1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“选择制造商 ID、制造商名称、制造商图像、日期添加、拉”附近使用正确的语法

选择计数(选择制造商 ID、制造商名称、制造商图像、添加日期、最后一次修改从制造商顺序按制造商名称)作为总数

请帮忙。非常感谢。

4

1 回答 1

0

I don't understand the need for your additional select statement within the SELECT COUNT()?

select count(*) as total

would do the same thing as:

select count(select manufacturers_id, manufacturers_name, manufacturers_image, date_added, last_modified from manufacturers order by manufacturers_name) as total

(if it were valid)

于 2013-07-23T10:45:24.090 回答