php - read individual img src from folder contents into HTML -


i trying write simple code, not sure use, javascript or php. have structured html docs , want insert image folder each img src attribute. need read in contents , insert each one, 1 one.

<div class="slideshow">         <div class="wrapper">             <ul>                 <li>                     <div class="main">                         <a href="product1.html"><img src="images/sample/name1-1.jpg" alt="" width="630" height="400" /></a>                     </div>                     <div class="second">                         <img src="images/sample/name1-2.jpg" alt="" width="310" height="190" />                     </div>                     <div class="third">                         <img src="images/sample/name1-3.jpg" alt="" width="310" height="190" />                     </div>                 </li> 

thanks might able steer me in right direction..

i using following code images directory

<?php  header("content-type: application/x-javascript");  function returnimages($dirname=".") { $pattern="(\.jpg$)|(\.png$)|(\.jpeg$)|(\.gif$)";  $files = array(); $curimage=0; if($handle = opendir($dirname)) { while(false !== ($file = readdir($handle))){ if(eregi($pattern, $file)){   echo 'galleryarray['.$curimage.']="'.$file .'";'; $curimage++; } }  closedir($handle); } return($files); }  echo 'var galleryarray=new array();';  returnimages()  ?> 

but @ point not sure how insert each file name src attribute

see here on how upload image floder using php here: http://www.w3schools.com/php/php_file_upload.asp

then once done uploading write insert query add table containing image details such image name , product id associated it

insert images (id, image_name, product_id) values ('myimage.jpg', '20');  

i assuming use auto increment 'id' field, primary key images.

then query images table product_id , image name add scr field as

$imagename = 'myimage.jpg';  <img src="images/<?=$imagename;?>" /> 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -