Пример #1
0
                    $rowimg = mysqli_fetch_assoc($res);
                    $imgpath = '/img/cat/' . $row3['cat_id'] . '/' . $rowimg['name'];
                    //echo $imgpath;
                    build_product($row3['name'], $row3['price'], $imgpath, $row3['url'], $row3['product_id']);
                }
            }
            echo '<br style="clear:both">';
        }
        ############# вывод всех продуктов из категорий потомков ###############
        #########Вывод продуктов которые относятся к конкретной категории#######
        $query = "SELECT * FROM `product` WHERE cat_id = {$row['id']}";
        $result2 = mysqli_query($db, $query);
        if (mysqli_num_rows($result2) > 0) {
            while ($row2 = mysqli_fetch_assoc($result2)) {
                //show_product($row2['name'], $row2['price']);
                $res = mysqli_query($db, "SELECT * FROM img WHERE product_id = {$row2['product_id']}");
                $rowimg = mysqli_fetch_assoc($res);
                #echo $rowimg['name'];
                #echo $row['id'];
                $imgpath = '/img/cat/' . $row['id'] . '/' . $rowimg['name'];
                #echo $imgpath;
                build_product($row2['name'], $row2['price'], $imgpath, $row2['url'], $row2['product_id']);
            }
            echo '<br style="clear:both">';
        }
        #########Вывод продуктов которые относятся к конкретной категории#######
    } else {
        header('Location: /404.html');
        exit;
    }
}
Пример #2
0
///////////////////////////////////////////////////////////
//	Генерация страницы ошибки при доступе вне системы
if (!defined('MY_KEY')) {
    header("HTTP/1.1 404 Not Found");
    exit(file_get_contents('./404.html'));
}
///////////////////////////////////////////////////////////
echo "\n<!-- ################ product ################### -->\n";
//echo $action; //это url
if (isset($action) and !empty($action)) {
    //Ищем категорию
    $query = "SELECT product.*, main.name AS cat_name, main.url AS cat_url, img.name AS img_name FROM product LEFT JOIN main ON product.cat_id = main.id LEFT JOIN img USING(product_id) WHERE product.url='{$action}'";
    $result = mysqli_query($db, $query);
    if (mysqli_num_rows($result) > 0) {
        $row = mysqli_fetch_assoc($result);
        $img = '/img/cat/' . $row['cat_id'] . '/' . $row['img_name'];
        $text = $row['pagetext'];
        $title = $row['title'];
        $keywords = $row['keywords'];
        $description = $row['description'];
        $cat_url = $row['cat_url'];
        $cat_name = $row['cat_name'];
        echo "<h1 class=\"first\">" . $title . "</h1>";
        echo '<p><a href="/cat/' . $cat_url . '">' . $cat_name . '</a></p>';
        build_product($row['name'], $img, $action, $row['product_id'], $text);
        build_product_character($row['product_id']);
    } else {
        header('Location: /404.html');
        exit;
    }
}