Здравствуйте, подскажите пожалуйста, как мне подсчитать количество выводимых строк в данном массиве, точнее создать новый массив который будет считать и вывести в smarty цифру?
global $db;
$limit_str = "";
if ($page) {
$limit_str = " limit " . $start . ", " . $no_per_page;
}
$messages_array = $db->fetchAssocList("select *, " . TABLE_MESSAGES . ".id as `msg_id`, " . TABLE_MESSAGES . ".pending as `pending`, date_format(" . TABLE_MESSAGES . ".`date`,'" . $date_format . "') as date_nice, " . TABLE_ADS . "." . $title_var . " as `title`, " . TABLE_MESSAGES . ".ip as ip from " . TABLE_MESSAGES . " left join " . TABLE_ADS . " on " . TABLE_ADS . ".id = " . TABLE_MESSAGES . ".ad_id left join " . TABLE_USERS . " on " . TABLE_USERS . ".id = " . TABLE_MESSAGES . ".`from` " . $where . " order by " . TABLE_MESSAGES . ".`" . $order . "` " . $order_way . $limit_str);
$i = 0;
foreach ($messages_array as $msg) {
$messages_array[$i]["message"] = cleanStr($messages_array[$i]["message"]);
$messages_array[$i]["title"] = cleanStr($messages_array[$i]["title"]);
$messages_array[$i]["from_contact_name"] = $msg[$settings["contact_name_field"]];
if ($messages_array[$i]["to"]) {
$contact_str = "";
if ($settings["contact_name_field"] != "email" && $settings["contact_name_field"] != "username") {
$contact_str = ", `" . $settings["contact_name_field"] . "`";
}
$user_info = $db->fetchAssoc("select email, username" . $contact_str . " from " . TABLE_USERS . " where id='" . $messages_array[$i]["to"] . "'");
$messages_array[$i]["to_contact_name"] = $user_info[$settings["contact_name_field"]];
$messages_array[$i]["to_email"] = $user_info["email"];
$messages_array[$i]["to_username"] = $user_info["username"];
}
$messages_array[$i]["blocked"] = $db->fetchRow("select count(*) from " . TABLE_BLOCKED_IPS . " where ip like '" . $messages_array[$i]["ip"] . "'");
$i++;
}
$no_messages = $this->noSearchMessages($where);
$this->no_messages = $no_messages;
return $messages_array;
}
на данный момент выводится в шаблон так, но это только на одну страницу, для всех сразу не подходит, все разваливается
if(!$_POST || !isset($post_array['type']) || !$post_array['type'])
$post_array['user_id'] = $crt_usr;
$smarty->assign("lng",$lng);
$smarty->assign("page",$page);
$smarty->assign("order",$order);
$smarty->assign("order_way",$order_way);
$smarty->assign("no_per_page",$no_per_page);
$smarty->assign("post_array",$post_array);
$messages_array=$msg->getMessages($post_array, $page,$no_per_page,$order,$order_way, 1);
$no_messages=$msg->getNoMessages();
$smarty->assign("no_messages",$no_messages);
$smarty->assign("messages_array",$messages_array);
шаблон
{isset($messages_array) && $messages_array|@count}