Roozbeh_1

yes, i have and nothing makes sense on php docs. EVER..

Roozbeh_1

Hello,

Happy new year guys..

I am trying to find a way to Upload and Display multiple images for one product on an ecommerce website that I am working on!

At the moment I can only upload one image for each product.

My current code is bellow:

This is upload.php

<?php 
// Script Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php 
include "../config/connect_to_mysql.php";
?>
<?php 
// Parse the form data and add inventory item to the system
if (isset($_POST['product_name'])) {

    $product_name = mysql_real_escape_string($_POST['product_name']);
    $price = mysql_real_escape_string($_POST['price']);
        $quantity = mysql_real_escape_string($_POST['quantity']);
    $category = mysql_real_escape_string($_POST['category']);
    $details = mysql_real_escape_string($_POST['details']);
    // See if that product name is an identical match to another product in the system
    $sql = mysql_query("SELECT id FROM products WHERE product_name='$product_name' LIMIT 1");
    $productMatch = mysql_num_rows($sql); // count the output amount
    if ($productMatch > 0) {
        echo 'Sorry you tried to place a duplicate "Product Name" into the system, <a href="add.php">click here</a>';
        exit();
    }
    // Add this product into the database now
    $sql = mysql_query("INSERT INTO products (product_name, price, quantity, details, category, date_added) 
        VALUES('$product_name','$price','$quantity','$details','$category',now())") or die (mysql_error());
     $pid = mysql_insert_id();
    // Place image in the folder 
    $newname = "$pid.jpg";
    move_uploaded_file( $_FILES['fileField']['tmp_name'], "../inventory_images/$newname");
    header("location: add.php"); 
    exit();
}
?>

<div id='wrapper'>
    <span id='about'>Welcome Admin</span>
    <div id='header'>
      <ul id='nav'>
     <li><a href='index.php'><span></span>Dashboard</a></li> 
           <li  class='active'><a href='upload.php'><span></span>Add Products</a></li> 
        <li><a href='logout.php'><span></span>Logout</a></li> 
        </ul>
    </div>
    <div id='content'>
        <div>
          <p><div align="left" style="margin-left:24px;">
      <h2>Inventory list</h2>
      <?php echo $product_list; ?>
    </div></p>
          <p><form action="add.php" enctype="multipart/form-data" name="myForm" id="myform" method="post">
    <table width="90%" border="0" cellspacing="0" cellpadding="6">
      <tr>
        <td width="20%" align="right">Product Name</td>
        <td width="80%"><label>
          <input name="product_name" type="text" id="product_name" size="64" /> ...