2. E – Commerce Website PHP Tutorial – MySQL Database and its Tables

click here

Series: http://www.developphp.com/video/PHP#eCommerce-Website-Tutorial
Source Download: http://www.developphp.com/video/PHP/PayPal-IPN-PHP-Instant-Payment-Notification-Script
In this 2nd video we will create the MySQL database and its tables. We demonstrate a scripted method for database table creation in this example. The E – Commerce Web Site we will be assembling is one in which all of the inventory is in a MySQL database and we offer a custom PHP cart for a unique shopping experience. It is a site that handles sales, customers, and inventory.


42 thoughts on “2. E – Commerce Website PHP Tutorial – MySQL Database and its Tables”

  1. see adam khoury in our language means any one who eats or kills a human … eg when a lion/dog/bear etc kills/eats humans he is called adam khour …
    just for fun dont take it seriously 😂😂😂

  2. You'll struggle with the create table files if you're using PHP 7.0 or newer. I recommend searching mysqli commands. If you're struggling shoot me a message, I have a copy of the files I used.

  3. This is a very good series, Outdated, but can be converted to PDO. I know that you can make the conversion if you try, most are repetitious. I will give you the one that I found hard. This is where I found it. php – PDO Echo 10 values order by descending – Stack Overflow.html. This is how I used it. // PRODUCT TABLE COLUM id product_name price details category subcategory date_added

    // you have to fetch the results in a array, and then echo the elements of the array.

    // $sql = "SELECT exp FROM login ORDER BY number DESC LIMIT 3";
    $sql = "SELECT id, product_name, price, details, date_added FROM products ORDER BY date_added DESC LIMIT 6";

    if ($stmt = $db->query($sql)) //PDO::query() returns a PDOStatement on success or false on failure.
    // If we got a PDOStatement as a return value from PDO::Query() fetch the results and echo.

    if($product_name = $stmt->fetch(PDO::FETCH_ASSOC)) // This will fetch all results in associative array.

    $row_count = $stmt->rowCount();

    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
    $id = $row["id"];
    $product_name = $row["product_name"];
    $price = $row["price"];
    $date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
    $dynamicList .= '<table width="100%" border="0" cellspacing="0" cellpadding="6">

    <td width="17%" valign="top"><a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="250"

    height="150" border="1" /></a></td>
    <td width="83%" valign="top">' . $product_name . '<br />
    100 Key Tags @ $' . $price . '<br />
    <a href="product.php?id=' . $id . '">View Product Details</a></td>
    } else {
    $dynamicList = "We have no products listed in our store yet";

    // mysql_close();

  4. This also may help:


    echo "<html>
    <head><title>Test MySQL</title></head>

    $host = "localhost";
    $user = "root";
    $password = "";
    $cxn = mysqli_connect($host, $user, $password);
    $sql = "SHOW DATABASES";
    $result = mysqli_query($cxn, $sql);

    if ($result == false) {
    echo "<h4>Error: ".mysqli_error($cxn)."</h4>";
    } else {
    if (mysqli_num_rows($result) < 1) {
    echo "<p>No current databases</p>";
    } else {
    echo "<ol>";
    while ($row = mysqli_fetch_row($result)) {
    echo "<li>$row[0]</li>";

    echo "</ol>";




  5. If you are viewing this in 2017, for your " connect_to_mysql.php" use the code below;
    $con = mysqli_connect("localhost","username","password","database");

    // Check connection
    if (mysqli_connect_errno())
    echo "Failed to connect to MySQL: " . mysqli_connect_error();

    and for your create_admin_table.php, use the code below;
    //connect to db


    $sql = "CREATE TABLE admin (
    id int(11) NOT NULL auto_increment,
    username varchar(255) NOT NULL,
    password varchar(255) NOT NULL,
    last_log_date date NOT NULL, PRIMARY KEY (id),
    UNIQUE KEY username (username) )";

    if ($con->query($sql) === TRUE) {
    echo "Table created successfully";
    } else {
    echo "Error creating table: " . $con->error;




  6. Hi Adam,
    I am trying to create a web page, after adding div and floating them when am trying to resize the window all divs overlaps, could you please share a tutorial how to overcome that issue. Like your website when I resize they don't overlaps I can see they are fixed where they are when the window was maximum and when I resize it the divs don't overlaps and a scroll bar appears at the browser window.

  7. @Adam Khoury your videos are amazing. Not sure if you have any info or could make a video on setting this whole thing up on a AWS EC2 Ubuntu LAMP stack instead of going through Cpanel? Would love to learn out to do that.

  8. Hi Adam Your Transaction Script For Paypal Do Not Contain Any Filed or Gathering Buyer's Phone Number From Paypal. As A part For Shipping Products Phone Number Is Really Essential Without Its In Complete.

  9. Thank you so much for your tutorials Adam Khoury…been watching from part 1 and still continuing. GOD BLESS YOU! watching all the way from KENYA, Happy coding viewers :). Cant thank you enough for how much you've made me understand php 🙂

  10. For those who are doing this tutorial, he's using PHP version 4 and not 5. So it's a bit outdated. For fixing create_admin_table.php use this code (don't forget to modify the variables):

    $db_host = "localhost"; 
    $db_username = "username";
    $db_pass = "password";
    $db_name = "dbname";

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

    $sqlCommand = "CREATE TABLE admin (
    id int(11) NOT NULL auto_increment,
    username varchar(255) NOT NULL,
    password varchar(255) NOT NULL,
    last_log_date date NOT NULL,
    PRIMARY KEY (id),
    UNIQUE KEY username (username)

    if(mysqli_query($link, $sqlCommand)) {
    echo "table created!";
    } else {
    echo "CRITICAL ERROR!";
    echo mysql_error();


  11. Can someone please explain to me how to see the message or various messages ‘Your admin table has been created successfully!"’ on the FTP screen? I have written the code correctly for all files and uploaded to my FTP server but all I get is a blank page? Also how do I get the admin table file into the ‘phpMyAdmin’ database?

  12. Hey Adam Khoury, I thank u for ur efforts for the tutorial! My question is when i tried to create a table on create_admin_table.php there z an error displayed on z browser!  May be instead for writing the query, it z easy to create a table in z phpmydmin page.. So could show me this steps.. Thank u!!

  13. hi Adam,
    having trouble with connecting the php to the sql database. I m getting a warning saying using connect_mysql has been deprecated…any advice on how to implement the connect using mysqli

  14. So i got sitename/create_admin_table.php to work and it succesfully created an admin table. However, the next step sitename/create_products_table.php , i get the Error message…. what do i do? i'm using fatcow and MySQL…. php admin…

Leave a Reply

Your email address will not be published. Required fields are marked *