Jump to content

Need Help on echoing multiple images


Hwoarang887

Recommended Posts

Hi guys, I need help on echoing multiple images that I put on one folder directory. 

 

Here is my upload code:

 

$pid = mysql_insert_id();

(mkdir("../inventory_images/$pid"));

    //place image in the folder 

$pid = mysql_insert_id();

    $newname = "$pid.jpg";

    $newname_a = "$pid.a.jpg";

    $newname_b = "$pid.b.jpg";

    $newname_c = "$pid.c.jpg";

    $newname_d = "$pid.d.jpg";

    $newname_e = "$pid.e.jpg";

    $newname_f = "$pid.f.jpg";

    $newname_g = "$pid.g.jpg";

    $newname_h = "$pid.h.jpg";

    move_uploaded_file($_FILES['fileField']['tmp_name'],"../inventory_images/$newname");

    move_uploaded_file($_FILES['fileFielda']['tmp_name'],"../inventory_images/$newname_a");

    move_uploaded_file($_FILES['fileFieldb']['tmp_name'],"../inventory_images/$newname_b"); 

    move_uploaded_file($_FILES['fileFieldc']['tmp_name'],"../inventory_images/$newname_c");

    move_uploaded_file($_FILES['fileFieldd']['tmp_name'],"../inventory_images/$newname_d");

    move_uploaded_file($_FILES['fileFielde']['tmp_name'],"../inventory_images/$newname_e");

    move_uploaded_file($_FILES['fileFieldf']['tmp_name'],"../inventory_images/$newname_f");

    move_uploaded_file($_FILES['fileFieldg']['tmp_name'],"../inventory_images/$newname_g");

    move_uploaded_file($_FILES['fileFieldh']['tmp_name'],"../inventory_images/$newname_h");

    header("location: inventory_list.php");

    exit();

 

}

 

 

Here is my echoing code

 

 

<?php

if (isset($_GET['id'])) {

// Connect to the MySQL database 

    include "storescripts/connect_to_mysql.php";

$id = preg_replace('#[^0-9]#i', '', $_GET['id']);

// Use this var to check to see if this ID exists, if yes then get the product

// details, if no then exit this script and give message why

$sql = mysql_query("SELECT * FROM products WHERE id='$id' LIMIT 1");

$productCount = mysql_num_rows($sql); // count the output amount

    if ($productCount > 0) {

// get all the product details

while($row = mysql_fetch_array($sql)){

$product_name = $row["product_name"];

$price = $row["price"];

$details = $row["details"];

$category = $row["category"];

$subcategory = $row["subcategory"];

$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));

 

        }

 

} else {

echo "That item does not exist.";

    exit();

}

 

} else {

echo "Data to render this page is missing.";

exit();

}

mysql_close();

?>

 

 

HTML Code:

 

<ul id="slider5">

 

<li><img src="inventory_images/<?php echo $id; ?>.jpg" width="550" height="507" alt="<?php echo $product_name; ?>" /></li>

 

<li><img src="inventory_images/<?php echo $id_a; ?>.jpg" width="550" height="507" alt="<?php echo $product_name; ?>" /></li>

 

<li><img src="inventory_images/<?php echo $id_b; ?>.jpg" width="550" height="507" alt="<?php echo $product_name; ?>" /></li>

 

<li><img src="inventory_images/<?php echo $id_c; ?>.jpg" width="550" height="507" alt="<?php echo $product_name; ?>" /></li>

       

        <li><img src="inventory_images/<?php echo $id_d; ?>.jpg" width="550" height="507" alt="<?php echo $product_name; ?>" /></li>

       

        <li><img src="inventory_images/<?php echo $id_e; ?>.jpg" width="550" height="507" alt="<?php echo $product_name; ?>" /></li>

       

        <li><img src="inventory_images/<?php echo $id_f; ?>.jpg" width="550" height="507" alt="<?php echo $product_name; ?>" /></li>

       

        <li><img src="inventory_images/<?php echo $id_g; ?>.jpg" width="550" height="507" alt="<?php echo $product_name; ?>" /></li>

       

        <li><img src="inventory_images/<?php echo $id_h; ?>.jpg" width="550" height="507" alt="<?php echo $product_name; ?>" /></li>

 

</ul>

   

 

I am able to echo <?php echo $id; ?> but the rest with $id_a, $id_b, $id_c, $id_d  I am not able.

 

 

Thank you all in advance

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.