Wordpress:产品显示在页面下方

时间:2015-05-07 22:35:07

标签: php wordpress

数据库中的产品显示正常,但它们显示在页面边界下方。不知道这是div问题,还是关于循环之前或之后输出的位置,还是......?请在此处查看:http://test5.walleyebaits.net/walleye-rods/

代码是:

<?php
/**
 * Template Name: Full Width Page
 *
 *
 * @package Ridizain
 * @since Ridizain 1.0
 */

get_header(); ?>

    <div id="primary" class="content-area">
        <div id="content" class="site-content" role="main">


            <?php
                // Start the Loop.
                while ( have_posts() ) : the_post();

                    // Include the page content template.
                    get_template_part( 'content', 'page' );

                    // If comments are open or we have at least one comment, load up the comment template.
                    if ( comments_open() || get_comments_number() ) {
                        comments_template();
                    }
                endwhile;
            ?>

<?php
//connect to the server and database

$db = mysqli_connect("localhost","xxxx","yyyy","test5_walleyebaits");
if (!$db) {
die("Database connection failed miserably: " . mysqli_error());
}

    $product_name = 'NAME';
    $product_desc = 'DESCRIPTION';
    $product_price = 'PRICE';
    $product_buy = 'BUYURL';
    $product_impression = 'IMPRESSIONURL';
    $product_image = 'IMAGEURL';

//query the database

$result = mysqli_query($db, "SELECT * FROM rods");
if (!$result) {
die("Database query failed: " . mysqli_error());
}

        while($rows = mysqli_fetch_array($result)) { 
    ?>

<div class="Table"> 

    <div class="Row">
        <div class="Cell1">
            <img src=<?php echo $rows[$product_image]; ?> width="195" height="195"/>
        </div>
    </div>

    <div class="Row">
        <div class="Cell2">
            <p><?php echo $rows[$product_name]; ?></p>
        </div>
    </div>

    <div class="Row">
        <div class="Cell3">
            <p>Our Price:    $<?php  echo $rows[$product_price];?></p>
        </div>
    </div>

    <div class="Row">
        <div class="Cell4">
            <a href="<?php echo $rows[$product_buy];?>"><p><img src="http://localhost/test5.walleyebaits/wp-content/uploads/2015/03/view_button.png" alt="view button"></p></a>
        </div>
    </div>

    <div class="Row">
        <div class="Cell5">
            <p><?php echo $rows[$product_desc]; ?></p>
        </div>          
    </div>

</div>

<!-- And so on--> 

     <?php   
        } 
     ?> 


        </div><!-- #content -->            
    </div><!-- #primary -->
</div><!-- #main-content -->

<?php
get_sidebar();
get_footer();

1 个答案:

答案 0 :(得分:0)

背景是div .entry-content。因此,它在你的循环模板中打开和关闭

                get_template_part( 'content', 'page' );

您需要将代码移动到该模板中,或者编辑CSS以应用于其他包装器。你的表格代码不在那个div里面。