|
|
|
|
$countries ="SELECT ord.orders_status, ord.customers_country, cn.countries_name, sts.orders_status_payed ";
$from ="FROM ex_orders ord, ex_orders_status sts, countries cn";
$where="WHERE sts.orders_status_payed = '1'
AND ord.orders_status = sts.orders_status_payed
AND ord.customers_country = cn.countries_name
AND ord.date_purchased
BETWEEN '2009-09-01'
AND '2010-03-01'";
if($_POST['nonepaid']){
$from.= ", " . TABLE_ORDERS_STATUS . " sts";
$where.= " AND ord.orders_status = sts.orders_status_payed";
}
|
НЕ МОГУ РАЗОБРАТСЬЯ В ЧЁМ ОШИБКА, | |
|
|
|
|
|
|
|
для: kaya
(13.04.2010 в 15:56)
| | какая ошибка? | |
|
|
|
|
|
|
|
для: root
(13.04.2010 в 18:52)
| |
#1064 - You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for
the right syntax to use near 'Country Orders Israel 3 Total
Countries: 1 LIMIT 0, 30' at line 2
|
ВОТ ОНА, РОДНАЯ | |
|
|
|
|
|
|
|
для: kaya
(13.04.2010 в 18:58)
| | Приведите текст SQL запроса, если сами не можете найти. Хотя MySQL Вам явно указал где ошибка. | |
|
|
|
|
|
|
|
для: root
(13.04.2010 в 19:03)
| |
SELECT ord.orders_status, ord.customers_country, cn.countries_name, sts.orders_status_payed
FROM ex_orders ord, ex_orders_status sts, countries cn
WHERE sts.orders_status_payed = '1'
AND ord.orders_status = sts.orders_status_payed
AND ord.customers_country = cn.countries_name
AND ord.date_purchased
BETWEEN '2009-09-01'
AND '2010-03-01'
|
Вот, кажись | |
|
|
|
|
|
|
|
для: kaya
(13.04.2010 в 19:19)
| | что значит кажись? Вы не знаете в каком запросе у Вас ошибка? | |
|
|
|
|
|
|
|
для: root
(13.04.2010 в 19:23)
| | *кажись*-это я так пошутила:):)
Это и есть мой запрос | |
|
|
|
|
|
|
|
для: kaya
(13.04.2010 в 19:58)
| | в приведенном Вами запросе нету ничего схожего с тем на что ругается MySQL | |
|
|
|
|
|
|
|
для: kaya
(13.04.2010 в 15:56)
| | Это всё какие-то разрозненные фрагменты.
Текст запроса после сборки (аргумент вызова mysql_query() ) Вы не приводите.
Очевидно, глядеть надо именно туда.
И скорее всего ошибка у Вас не в выполнении запроса, в алгоритме сборки еще до выполнения.
То есть в PHP. | |
|
|
|
|
|
|
|
для: Trianon
(13.04.2010 в 20:49)
| | Здрасте всем:)
Вот мой код целиком:
$countries ="SELECT ord.orders_status, ord.customers_country, cn.countries_name, sts.orders_status_payed " ;
$from="FROM ex_orders ord, ex_orders_status sts, countries cn " ;
$where= " WHERE sts.orders_status_payed = '1'
AND ord.orders_status = sts.orders_status_payed
AND ord.customers_country = cn.countries_name
AND ord.date_purchased
BETWEEN '2009-09-01'
AND '2010-03-01'";
if($_POST['paid']){
$from.= ", " . EX_ORDERS_STATUS . " stat";
$where.= " AND ord.customers_country = cn.countries_name";
}
echo $countries.$from.$where;
$query=Tep_db_query($countries.$from.$where);
while ($country =Tep_db_fetch_array ($query)){
if(isset($temp[$country['customers_country']])){
//$temp[$country['customers_country']]['num_orders']++;
$temp[$country['customers_country']]++;
}else{
//$temp[$country['customers_country']]=array('countries_id'=>$country['countries_id'],
//'num_orders'=>1);
$temp[$country['customers_country']]=1;
}
}
arsort($temp);
|
Буду очень благодарна за любую помощь:):) | |
|
|
|
|
|
|
|
для: kaya
(14.04.2010 в 12:49)
| | что-то Вы не то постите все равно... | |
|
|
|
|
|
|
|
для: kaya
(14.04.2010 в 12:49)
| | Но я здесь не вижу ни текста запроса, ни даже обращения к БД. | |
|
|
|
|
|
|
|
для: Trianon
(14.04.2010 в 13:41)
| |
$query=Tep_db_query($countries.$from.$where)
|
Это разве не обращение? | |
|
|
|
|
|
|
|
для: kaya
(14.04.2010 в 14:08)
| | А как это выглядит? | |
|
|
|
|
|
|
|
для: kaya
(14.04.2010 в 14:09)
| | Спасибо всем, всем, всем за помощь:):)
Если кому-то могут помочь мои потуги в php представляю окончательный вариант:
if(isset($_POST['fromdate'])){
$fromdate = $_POST['fromdate'];
$todate=$_POST['todate'];
}else{
$fromdate='01/'.date('m/Y');
$todate=date('d/m/Y');
echo "No results found";
exit;
}
$countries ="SELECT ord.orders_status, ord.customers_country " ;
$from="FROM ex_orders AS ord " ;
$where= "WHERE ord.date_purchased BETWEEN '".guion($fromdate)."' AND '".guion($todate)."' AND ord.orders_status = '3'";
//$countries ="SELECT ord.orders_status, ord.customers_country, cn.countries_name, sts.orders_status_payed " ;
//$from="FROM ex_orders AS ord, ex_orders_status AS sts, countries AS cn " ;
//$where= "WHERE ord.date_purchased BETWEEN '2009-09-01' AND '2010-03-01' AND ord.customers_country = cn.countries_name AND ord.orders_status = '3' ";
if($_POST['paid']){
// $from.= "," . EX_ORDERS_STATUS . " stat";
$where= "WHERE ord.date_purchased BETWEEN '".guion($fromdate)."' AND '".guion($todate)."'";
}
//echo $countries.$from.$where;
$query=Tep_db_query($countries.$from.$where);
while ($country =Tep_db_fetch_array ($query)){
if(isset($temp[$country['customers_country']])){
//$temp[$country['customers_country']]['num_orders']++;
$temp[$country['customers_country']]++;
}else{
//$temp[$country['customers_country']]=array('countries_id'=>$country['countries_id'],
//'num_orders'=>1);
$temp[$country['customers_country']]=1;
}
}
arsort($temp);
|
Спасибо всем ещё раз:):):) | |
|
|
|
|
|
|
|
для: kaya
(14.04.2010 в 14:08)
| | не знаю... Это некий вызов функции. Что это за функия, и чем примерно занимается, можно конечно предположить.
Но лишь предположить. Как она детально устроена и что с аргументом делает - здесь не видно.
Даже если аргумент ну ооочень похож на текст запроса. А ведь Вы не показали даже этого. | |
|
|
|
|
|
|
|
для: Trianon
(14.04.2010 в 15:19)
| | Вы были правы,я изменила код. Вот окончательный вариант:
if(isset($_POST['fromdate'])){
$fromdate = $_POST['fromdate'];
$todate=$_POST['todate'];
}else{
echo "No results found";
exit;
}
$countries = "SELECT ord.orders_status, ord.customers_country " ;
$from = "FROM " . TABLE_ORDERS . " ord ";
$where = "WHERE ord.date_purchased BETWEEN '".guion($fromdate)."' AND '".guion($todate)."' ";
if($_POST['paid']){
$select .= ", stat.orders_status_payed ";
$from.= ", " . EX_ORDERS_STATUS . " stat ";
$where.= " AND stat.orders_status_payed = '1' AND ord.orders_status = stat.orders_status_id ";
}
$query=Tep_db_query($countries.$from.$where);
$temp = array();
while ($country =Tep_db_fetch_array ($query)){
if(isset($temp[$country['customers_country']])){
//$temp[$country['customers_country']]['num_orders']++;
$temp[$country['customers_country']]++;
}else{
//$temp[$country['customers_country']]['num_orders'] = 1;
$temp[$country['customers_country']] = 1;
}
}
arsort($temp);
|
Ещё раз огромное спасибо:):) | |
|
|
|