$sql = 'SELECT * FROM users WHERE id = "'.$idUser.'" ';
$result = mysqli_query($link,$sql);
$arr = array();
while ($row = mysqli_fetch_assoc($result)) { ?>
<div class="text-muted mb-1 mt-1">E-Mail/Логин</div>
<span class="mt-1"><?=$row['email']?></span>
<div class="text-muted mb-1 mt-1">ФИО</div>
<span class="mt-1"><?=$row['f']?> <?=$row['i']?> <?=$row['o']?></span>
<div class="text-muted mb-1 mt-1">Телефон</div>
<span class="mt-1"><?=$row['phone']?></span>
<div class="text-muted mb-1 mt-1">Компания</div>
<span class="mt-1"><?=$row['company']?></span>
<div class="text-muted mb-1 mt-1">Город</div>
<span class="mt-1"><?=$row['city']?></span>
<?php
}
<div class="card mb-3">
<div class="card-body">
<div id="content"></div>
</div>
</div>
<script type='text/javascript'> toastr.danger('Подтвердите, что Вы не робот!')</script>
Array
(
[Dealers] => Array
(
[0] => Array
(
[id_city] => 1
[name_city] => Ачинск
[dealers] => Array
(
[0] => Array
(
[dealer_id] => 1
[dealer_name] => Дилер
[dealer_phone] => телефон
[dealer_email] => емейл
[dealer_site] => сайт
)
)
)
[1] => Array
(
[id_city] => 2
[name_city] => Барнаул
[dealers] => Array
(
[0] => Array
(
[dealer_id] => 1
[dealer_name] => Дилер
[dealer_phone] => телефон
[dealer_email] => емейл
[dealer_site] => сайт
)
[1] => Array
(
[dealer_id] => 2
[dealer_name] => Дилер
[dealer_phone] => телефон
[dealer_email] => емейл
[dealer_site] => сайт
)
[2] => Array
(
[dealer_id] => 3
[dealer_name] => Дилер
[dealer_phone] => телефон
[dealer_email] => емейл
[dealer_site] => сайт
)
[3] => Array
(
[dealer_id] => 4
[dealer_name] => Дилер
[dealer_phone] => телефон
[dealer_email] => емейл
[dealer_site] => сайт
)
[4] => Array
(
[dealer_id] => 5
[dealer_name] => Дилер
[dealer_phone] => телефон
[dealer_email] => емейл
[dealer_site] => сайт
)
)
)
)
)
$sql = 'SELECT (SELECT COUNT(*) FROM `dilery` WHERE dilery.city_dil = city.id_city AND dilery.`status` != 1) as `count`, city.name_city, city.id_city
FROM dilery
INNER JOIN city ON dilery.city_dil = city.id_city
WHERE city.region != "1" AND dilery.`status` != 1
GROUP BY name_city
ORDER BY name_city';
$row_dealers = mysqli_query($link,$sql);
$dealersDetails = array();
if(mysqli_num_rows($row_dealers) > 0) {
$dealersCount = 0;
while ($city = mysqli_fetch_assoc($row_dealers)) {
$idCity = $city['id_city'];
$name = $city['name_city'];
$dealersDetails[$dealersCount] = $city;
$sql = 'SELECT dilery.name_dil, dilery.phone_dil, dilery.email_dil, dilery.site_dil
FROM dilery
INNER JOIN city ON dilery.city_dil = city.id_city
WHERE dilery.city_dil = '.$idCity.' AND dilery.`status` != 1
ORDER BY name_city';
$row_dealers_item = mysqli_query($link,$sql);
if(mysqli_num_rows($row_dealers_item) > 0) {
while ($dealers = mysqli_fetch_assoc($row_dealers_item)) {
$dealersDetails[$dealersCount]['dealers'] = $dealers;
$dealersDetails[$dealersCount]['name_city'] = $name;
}
} else {
$dealersDetails[$dealersCount]['dealers'] = [];
}
echo '<pre>';
print_r($dealersDetails);
echo '</pre>';
}
}
Array
(
[0] => Array
(
[count] => 1
[name_city] => Абакан
[id_city] => 46
[dealers] => Array
(
[name_dil] => Дилер 1
[phone_dil] => Телефон
[email_dil] => Емейл
[site_dil] => Сайт
)
)
)
Array
(
[0] => Array
(
[count] => 1
[name_city] => Ачинск
[id_city] => 1
[dealers] => Array
(
[name_dil] => Дилер 1
[phone_dil] => Телефон
[email_dil] => Емейл
[site_dil] => Сайт
)
)
)
Array
(
[0] => Array
(
[count] => 5
[name_city] => Барнаул
[id_city] => 2
[dealers] => Array
(
[name_dil] => Дилер 1
[phone_dil] => Телефон
[email_dil] => Емейл
[site_dil] => Сайт
)
)
)
$sql = "SELECT filialy.city, filialy.link_filial, city.name_city, city.countryId, city.id_city
FROM filialy
INNER JOIN city ON filialy.cityId = city.id_city
WHERE filialy.activity = 1
ORDER BY filialy.city";
$result = mysqli_query($link,$sql);
$data = [];
while ($row = mysqli_fetch_array($result)) {
$product = [
'name' => $row['city'],
'countryId' => $row['countryId'],
'link' => $row['link_filial'],
];
if (!isset($data[$row['id_city']])) {
$row['id_city'] = [
'products' => [$product]
];
} else {
$row['id_city']['products'][] = $product;
}
echo "<pre>";
print_r($product);
echo "</pre>";
}
Array
(
[name] => Алматы
[countryId] => 39
[link] => almaty/
)
Array
(
[name] => Барнаул
[countryId] => 80
[link] => barnaul/
)
Array
(
[name] => Волгоград
[countryId] => 80
[link] => volgograd/
)
Array
(
[name] => Воронеж
[countryId] => 80
[link] => voronej/
)
function getCat($link){
$sql = "SELECT * FROM category ORDER BY sort,id";
$result = mysqli_query($link,$sql);
//Создаем масив где ключ массива является ID меню
$cat = array();
while ($row = mysqli_fetch_assoc($result)) {
$cat[$row['id']] = $row;
}
return $cat;
}
function getTree($dataset) {
$tree = array();
foreach ($dataset as $id => &$node) {
//Если нет вложений
if (!$node['parent_id']){
$tree[$id] = &$node;
}else{
//Если есть потомки то перебераем массив
$dataset[$node['parent_id']]['childs'][$id] = &$node;
}
}
return $tree;
}
$cat = getCat($link);
//Создаем древовидное меню
$tree = getTree($cat);
//Шаблон для вывода меню в виде дерева
function tplMenu($category){
$menu = '<li>
<a href="#" title="'. $category['name'] .'">'.
$category['name'].'</a>';
if(isset($category['childs'])){
$menu .= '<ul>'. showCat($category['childs']) .'</ul>';
}
$menu .= '</li>';
return $menu;
}
/**
* Рекурсивно считываем наш шаблон
**/
function showCat($data){
$string = '';
foreach($data as $item){
$string .= tplMenu($item);
}
return $string;
}
//Получаем HTML разметку
$cat_menu = showCat($tree);
//Выводим на экран
echo '<ul>'. $cat_menu .'</ul>';
$sql = 'SELECT * FROM promo LIMIT 30