图片和产品信息未显示在页面上

时间:2018-07-30 04:07:24

标签: php html css mysqli

曾经在我妻子的珠宝网站的产品页面上工作。我从一个教程中添加了php,并试图运行该页面。包括页眉在内的所有图像均未与页脚一起显示。它们显示在其他页面上。信息产品也没有出现。该页面显示连接已打开,我没有收到任何错误。导航与一些CSS一起显示,但仅此而已。

这是我正在使用的代码。

       <?php 
        error_reporting(E_ALL);
        ini_set('display_startup_errors', 1);
        ini_set('display_errors', 1);
        ?>
        <?php 
        if (isset($_GET['id'])) {
            // Connect to the MySQL database  
            include_once("storescripts/connect_to_mysql.php");
            $con = 





              mysqli_connect("$db_host","$db_username","$db_pass","$db_name"); 

            if (mysqli_connect_errno()) {
            printf("Connect failed: %s\n", mysqli_connect_errno());
            exit();


        } $id = preg_replace('#[^0-9]#i', '', $_GET['id']); 
            $sql = "SELECT * FROM products WHERE category='Bracelets';";
            $result = mysqli_query($con, $sql);
            $resultCheck = mysqli_num_rows($result);
            if ($resultCheck > 0) {
                // get all the product details
                while($row = mysqli_fetch_assoc($result)); { 
                     $item_number = $row["item_number"];
                     $price = $row["price"];
                     $desc = $row["description"];
                     $category = $row["category"];
                 }

            } else {
                echo "Data to render this page is missing.";
                exit();
            }
        }
        ?>
        <!DOCTYPE html>
        <html>
        <head>
            <title>Bracelets</title>
            <meta charset="utf-8">
            <meta http-equiv="x=UA-comparable" content="IE-edge">
            <meta name="description" content="Pinky's Pearls is a website where 
            one 
            of a kind jewelry designed by Nichole <q>Nicki</q> can be seen and 
            purchased">
            <meta name="keywords" content="jewelry, beads, bracelets, rings, 
            pendants, necklaces, pearls, crystal">
            <meta name="viewpoint" content="width=device-width, initial-scale=1">
            <meta name="author" content="samuel jaycox">
            <link href="style.css" rel="stylesheet">
            <link rel="stylesheet" 
             href="https://cdnjs.cloudflare.com/ajax/libs/font- 
            awesome/4.7.0/css/font-awesome.min.css">
            <link rel="shortcut icon" type="image/png" href="pictures/pinky.png">
            <script src="https://use.fontawesome.com/0c9491c5b9.js"></script>
        </head>
        <body>
            <div align="center"  id="wrapper">
            <div id="banner-wrapper">
            <?php 



  include_once("c:/xampp/htdocs/pinkys_pearls/templates/template_bracelets.php"); 
            ?>
                <br>
            <?php include_once("templates/template_navigation.php"); ?>     
                <br>
                <br>
                <br>
        <!--Start Comment page Body Content-->
        <div id="body-content">
            <div class="bracelet_body">
                <table width="100%" border="2" cellspacing="0" cellpadding="15">
          <tr>
            <td width="19%" valign="top"><img src="pictures/inventory/<?php echo 
        $pid; ?>.png" width="142" height="188" alt="<?php echo $item_number; ?>" 
        /> 
       <br />
              <a href="pictures/inventory/<?php echo $pid; ?>.png">View Full Size 
        Image</a></td>
            <td width="81%" valign="top"><h3><?php echo $item_number; ?></h3>
              <p><?php echo "$".$price; ?><br />
                <br />
                <?php echo $desc; ?>
        <br />
                </p>
              <form  id="form1" name="form1" method="post" action="cart.php">
                <input type="hidden" name="pid" id="pid" value="<?php echo $id; ? 
         >" 
        />
                <input class="button" type="submit" name="button" id="button" 
       value="Add to Shopping Cart" />
              </form>
              </td>
            </tr>
        </table>
            </div>
        </div>
        <!--end of Comment body-->
        <?php include_once('templates/template_footer.php'); ?>">
        </body>
        </html>

1 个答案:

答案 0 :(得分:0)

请确保您的路径正确!

尝试更改您的链接

<?php include_once("c:/xampp/htdocs/pinkys_pearls/templates/template_bracelets.php"); ?>

<?php include_once("c:/xampp/htdocs/pinkys_pearls/templates/template_navigation.php"); ?>

<?php include_once("localhost/pinkys_pearls/templates/template_bracelets.php"); ?>

<?php include_once("localhost/pinkys_pearls/templates/template_navigation.php"); ?>

确保您的图像路径,如果文件夹不同,您将无法加载图像。