我的产品从数据库导入很好,但我在wordpress文本编辑器中输入的介绍内容插入页面底部: 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
//connect to the server and database
$db = mysqli_connect("servername","username","password","dbname");
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
}
?>
<?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;
?>
</div><!-- #content -->
</div><!-- #primary -->
</div><!-- #main-content -->
<?php
get_sidebar();
get_footer();