how do i display product information when they click on the product

141
April 10, 2017, at 07:39 AM

I have been having issues figuring out how to display product information when the user clicks on the product. So far i have the product page setup and a sort feature everything else i have tried breaks it.

<?php
        require_once('includes/database.php');
        $page_title = 'Classic Models | Products';
    ?>`enter code here`
    <?php include('includes/header.html.php'); ?>
     <?php 
    $sort = isset($_GET['sort']) ? $_GET['sort'] : 'Name';

    $sql= "SELECT productName, productDescription, buyPrice
    FROM `Products`
    ORDER BY $sort";
    $result = mysqli_query($db, $sql);
    // get the sort order from the url

    if(mysqli_num_rows($result)){
        //echo var_dump($result);
        echo '<table>';
        echo '<tr>
                <th><a href="?sort=ProductName">Product</a></th>
                <th>ProductDesription</th>
                <th><a href="?sort=BuyPrice">Price</a></th>
            </tr>';

        while($row = mysqli_fetch_array($result)){
        //'<pre>'. var_dump($row). '</pre>'; to show the loop worked
        //echo '<li>'. $row['productName'] . $row['productDescription'] . $row['buyPrice'] . '</li>' ; 
             //to get my products to show in a table.
    echo
                "<tr>
                  <td>{$row['productName']}</td>
                  <td>{$row['productDescription']}</td>
                  <td>{$row['buyPrice']}</td>

                </tr>";
        } 
        echo '</table>';
        }else{
            echo "Results not found";
    }


    //my footer 
    ?>
    <?php include('includes/footer.html.php'); ?>
READ ALSO
Best way to store users messages: MySQL Database or elsewhere?

Best way to store users messages: MySQL Database or elsewhere?

I have a site where users can post messages (around 400 characters) which can also include images and I need to store these massages somewhereI was wondering what would be the best way to do this

156
from Sqlite3 to Mysql in django chatbot website

from Sqlite3 to Mysql in django chatbot website

i'ev developed a chatbot web application using Django and python3 on web faction serverBasically the chatbot interacts with a store's users as a customer server

326
How to use select Case in the following SQL query

How to use select Case in the following SQL query

I have two tables users and userdetailI am trying to create a view in which if status of userdetail column is 1 it should show Active in view and blocked if status is 0

199
Uploading CSV file into mysql database using PHP

Uploading CSV file into mysql database using PHP

I am having a problem uploading a CSV file into my MySQL databaseI'm not a very experienced coder so sorry if my attempt at solving the problem is way off, but I am going to include what I have tried so far

182