I want to retrieve the image from the database and want to display it in a row like if there is 20 images in a database then it should get display in 5 rows containing 4 images in each row...
My code is working properly but i am facing problem in image path as i hv stored the image-name in database and image inside admin/uploads folder.... like uploads folder is inside the admin folder... adminfolder/uploadsfolder/file-name
here in my code i am getting problem in tracing the image path.....
Expand|Select|Wrap|Line Numbers
- echo "<td><img src=\"".$path[$i]."\" height='100'/></td>";
Expand|Select|Wrap|Line Numbers
- <?php
- mysql_connect('localhost','root','') or die(mysql_error());
- mysql_select_db('dogs_db') or die(mysql_error());
- $sql = "SELECT file_name FROM dogsinfo";
- $res = mysql_query($sql) or die(mysql_error());
- echo "<table><tr>";
- while($fetch = mysql_fetch_assoc($res)) {
- $path[] = $fetch['file_name'];
- }
- for($i=0;$i<count($path);$i++){
- if($i%4 == 0){
- echo "</tr>";
- }
- // I am Facing Problem here ...
- // my all images is in admin/uploads folder
- echo "<td><img src=\"".$path[$i]."\" height='100'/></td>";
- }
- echo "</tr></table>";
- ?>
Please help me to sort out this.... I am new to php