基于导航选择加载php元素

时间:2015-09-25 18:34:29

标签: php html sorting conditional-statements

我想要它,以便当用户点击将其带到网站的生日部分的链接时,它只会从生日文件夹中加载图像。我已经定义了类别,但似乎无法使其正常工作。它应该是img / catagory / filename。

<body>
<main>

<?php
//bring in external files
include_once('config/spc_database.php');
include_once('object/cake.php');

//make a db object:
$database = new Database();

//make it connect:
$conn=$database->getConnection();
//instantiate a new movie object
$cake =  new Cake($conn);
//get the id being passed in the URL query string($_GET array)
//and store it in the id property for the Cake object
$cake->id = $_GET['detailsid'];

//run a SELECT * query with WHERE so it gets one row
$stmt = $cake->readDetails();
//loop through that variable, repeating a procedure once per row            
?>

<div id="container" class="group">
    <div class="left-content">
    <?php
    while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
    ?>
        <div class="main-description-image">
            <img src="img/all_cakes/<?php echo $row['large']; ?>" alt="placeholder" class="large-img"/>
        </div>
        <div class="cake-descript-info">
            <h2 class="header-title"><?php echo $row['name']; ?></h2>
            <p class="body-text-descript"><?php echo $row['description']; ?></p>
            <span class="prices">Cost: $<?php echo $row['price']; ?></span>
        </div>
    </div>
</div>
<div class="container-img">
    <div class="dropdown-description styled-select">
        <select id="Category">
            <option value="hide">-- Pick a category --</option>
            <option value="Wedding cakes">Wedding cakes</option>
            <option value="Birthday cakes">Birthday cakes</option>
            <option value="Cupcakes">Cupcakes</option>
            <option value="Specialty sweets">Specialty sweets</option>
            <option value="Traditional">Traditional</option>
            <option value="Modern">Modern</option>
            <option value="Themed">Themed</option>
            <option value="Festive">Festive</option>
        </select> 
    </div>
    <div class="top-left-box-description hvr-grow">     
        <a href="description.php?detailsid=<?php echo $row['id'];?>"> <img src="img/<?php echo $row['category']; ?>/<?php echo $row['thumb']; ?>" </a>
    </div>
    <div class="top-right-box-description hvr-grow">
        <a href="description.php?detailsid=<?php echo $row['id'];?>"> <img src="img/all_cakes/<?php echo $row['thumb']; ?> " class="tmbnails"</a>
    </div>
    <div class="bottom-left-box-description hvr-grow">
        <img src="img/small-thumbnail-placeholder3.jpg" class="tmbnails" alt=""/>
    </div>
    <div class="bottom-right-box-description hvr-grow">
        <img src="img/small-thumbnail-placeholder4.jpg" class="tmbnails" alt=""/>
    </div>
    <div class="bottom-order-description">  
        <section class="buttons">
            <div class="container-btn"> 
                <a href="#" class="btn btn-3">Order</a> 
            </div>
        </section>
    </div>
</div>         
<?php 
}
?>  

1 个答案:

答案 0 :(得分:0)

该页面是一个读取详细信息,读取所有类别但读取详细信息没有 $ stmt = $ this-&gt; conn-&gt; prepare(&#39; SELECT id,name,category,description,price,thumb,large FROM&#39;。$ this-&gt; table_name。&#39; WHERE ID =&#39; $这 - &GT; ID);