Hwoarang887 Posted June 13, 2012 Share Posted June 13, 2012 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 Quote Link to comment Share on other sites More sharing options...
Barand Posted June 13, 2012 Share Posted June 13, 2012 When you save the files the names are $pid.a.jpg You are trying to display $id_a.jpg Also as "_" is a legal char in a variable name you would need "{$id}_a.jpg" if you decide on "_" instead of "." Quote Link to comment Share on other sites More sharing options...
Hwoarang887 Posted June 13, 2012 Author Share Posted June 13, 2012 Hi thank you for the reply heres my output <li><img src="inventory_images/<?php echo $id.a; ?>.jpg" width="550" height="507" alt="<?php echo $product_name; ?>" /></li> Still does not show the image Thank you again Quote Link to comment Share on other sites More sharing options...
Barand Posted June 13, 2012 Share Posted June 13, 2012 If you view the page source, does it look right? Quote Link to comment Share on other sites More sharing options...
Hwoarang887 Posted June 13, 2012 Author Share Posted June 13, 2012 Hi again It looks correct it shows no error. But the picture still does not show. Thank you for your time Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.