Не нравятся результаты поиска? Попробуйте другой поиск!
DLE FAQ » Все вопросы » Общие вопросы по PHP » Как правильно выводить строки из базы?

Как правильно выводить строки из базы?


     17.02.2015    Общие вопросы по PHP, Модули, MySQL    3607

вопрос
Пишу модуль по контролю груза для не большого магазина.
Но если более 10 грузов начинаются чудеса
То есть
Грузов 11 а видим 5 или 6 чистим кеш видим новое значение и так до бесконечности
Код вывода

if (!defined('DATALIFEENGINE'))
{
        die("Hacking attempt!");
}
if ($is_logged == 'true')
{
        $crm_kl = dle_cache("crm_klient" . $member_id['name'], $config['skin']);
        if (!$crm_kl)
        {
                $checkid = $db->query("SELECT * FROM " . PREFIX ."_crm WHERE ux='0' ORDER BY RAND()");
                if ($db->num_rows($select) > 0)
                {
                        while ($row = $db->get_row($select))
                        {
                                $tpl->load_template('crm_kl.tpl');

                                $tpl->set("{id}", $row['id']);
                                $tpl->set("{id-user}", $row['id-user']);
                                $tpl->set("{data-ot-user}", $row['data-ot-user']);

                                if ($row['data-ot-sklad'] == '0000-00-00')
                                {
                                        $data_ot_sklad = 'В пути';
                                }
                                else
                                {
                                        $data_ot_sklad = $row['data-ot-sklad'];
                                }
                                $tpl->set("{data-ot-sklad}", $data_ot_sklad);

                                $tpl->set("{ves-user}", $row['ves-user']);

                                if ($row['up'] == '0')
                                {
                                        $up = 'Нет';
                                }
                                else
                                {
                                        $id_up = $row['up'];
                                        $checkid = $db->query("SELECT * FROM " . PREFIX . "_up WHERE id_up='$id_up' ");
                                        $row1 = $db->get_row($select);
                                        $up = $row1['name'];
                                }
                                $tpl->set("{up}", $up);

                                if ($row['ves'] == '')
                                {
                                        $ves = 0;
                                }
                                else
                                {
                                        $ves = $row['ves'];
                                }
                                $tpl->set("{ves}", $ves);

                                if ($row['obem'] == '')
                                {
                                        $obem = 0;
                                }
                                else
                                {
                                        $obem = $row['obem'];
                                }
                                $tpl->set("{obem}", $obem);

                                if ($row['spos-get'] == '1')
                                {
                                        $spos_get = 'Авиа';
                                }
                                else
                                {
                                        $spos_get = 'По земле';
                                }
                                $tpl->set("{spos-get}", $spos_get);

                                $tpl->set("{status}", $status);

                                if ($row['data-ux'] == '0000-00-00')
                                {
                                        if ($data_ot_sklad == 'В пути')
                                        {
                                                $data_ux = 'Неизвестна';
                                        }
                                        else
                                        {
                                                $data_ux = 'На складе';
                                        }
                                }
                                else
                                {
                                        $data_ux = $row['data-ux'];
                                }
                                $tpl->set("{data-ux}", $data_ux);

                                $tpl->set("{coment}", $row['coment']);

                                if ($row['sklad'] == '2')
                                {
                                        $sklad = 'Гуанчжоу';
                                }
                                else
                                {
                                        $sklad = 'Пекин';
                                }
                                $tpl->set("{sklad}", $sklad);

                                $tpl->set("{name-gruse}", $row['name-gruse']);


                                $tpl->compile('crm_kl');
                                $crm_kl = $tpl->result['crm_kl'];
                                create_cache("crm_klient" . $member_id['name'], $crm_kl, $config['skin']);
                                $tpl->clear();
                        }
                }
        }
        echo $crm_kl;
}
else
{
        echo 'Что-то пошло не так =(';
}

пробовал задавать лимит результат один, а без ORDER BY RAND() выводит только 1 строку

Ответил: Goot


Всем спасибо сам понял, что перенесенные $select пересеклись
Чтобы комментировать - войдите или зарегистрируйтесь на сайте

Похожие вопросы

наверх