Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Trying to get info from a table to display on my html front. But it doesn't want to.

functions file
PHP
function get_products()
{
    $query = query(" SELECT * FROM products");

    confirm($query);

    while($row = fetch_array($query))
    {
        $product = <<<DELIMETER

            <div class="col-sm-4 col-lg-4 col-md-4">
                <div class="thumbnail">
                    <img src="http://placehold.it/320x150" alt="">
                    <div class="caption">
                        <h4 class="pull-right">{$row['product_price']}</h4>
                        <h4><a href="#">Fifth Product</a>
                        </h4>
                        <p>This is a short description. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
                        <a class="btn btn-primary" target="_blank" href="http://maxoffsky.com/code-blog/laravel-shop-tutorial-1-building-a-review-system/">View Tutorial</a>
                    </div>
                    
                </div>
            </div>
DELIMETER;

echo $product;
     
    }
}


html
PHP
<?php
require_once("../resources/config.php");
?>
<?php
include(TEMPLATE_FRONT . DS . "header.php");
?>
    <!-- Page Content -->
    <div class="container">

        <div class="row">

            <?php
            include(TEMPLATE_FRONT . DS . "side_nav.php");
            ?>

            <div class="col-md-9">

                <div class="row carousel-holder">

                    <div class="col-md-12">
                        <?php
                        include(TEMPLATE_FRONT . DS . "slider.php");
                        ?>
                    </div>

                </div>

                <div class="row">

                    <?php
                    get_products();
                    ?>

                </div> <!--  Row ends here -->

            </div>

        </div>

    </div>
    <!-- /.container -->

<?php
include(TEMPLATE_FRONT . DS . "footer.php");
?>




And config that links two file, just in case
PHP
<?php

ob_start();

session_start();

//Rout constant
defined("DS") ? null : define("DS", DIRECTORY_SEPARATOR);
//Templates constant
defined("TEMPLATE_FRONT") ? null : define("TEMPLATE_FRONT", __DIR__ . DS . "template/front");
defined("TEMPLATE_BACK") ? null : define("TEMPLATE_BACK", __DIR__ . DS . "template/back");
//DB Connection constant
defined("DB_HOST") ? null : define("DB_HOST", "localhost");
defined("DB_USER") ? null : define("DB_USER", "root");

defined("DB_PASS") ? null : define("DB_PASS", "mysql");
defined("DB_NAME") ? null : define("DB_NAME", "ecom_db");

$connection = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);

require_once("functions.php");


What I have tried:

Tried fixing the syntax and looking at different code to get the same result.
Posted
Updated 12-Jan-21 0:09am
v3
Comments
Patrice T 12-Jan-21 6:07am    
And you have an error message ?
Demetri K.2 12-Jan-21 8:24am    
Nop, no message.
Richard MacCutchan 12-Jan-21 6:38am    
I don't see any code that actually executes the SELECT statement.
Demetri K.2 12-Jan-21 8:25am    
Strange, I'm doing this based on a tutorial, which is working for the author of the tutorial. So What should I change?
Richard MacCutchan 12-Jan-21 8:48am    
Why not ask the author of the tutorial?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900