0

How to select image from folder by name in mysql.
This is mysql query for other rows

$query = "SELECT `posts`.`id` AS `post_id`, `categories`.`id` AS `category_id`,`title`,`contents`,`date_posted`
  ,`categories`.`name` FROM `posts` INNER JOIN `categories` ON `categories`.`id`= `posts`.`cat_id`";

how to select row 'image' where is name of image and call that image from folder?

4
Contributors
5
Replies
21
Views
3 Years
Discussion Span
Last Post by gogs85
0
$image_name_from_db=get_image_name_from_db();
$images_dir=dir("url/images/dir");
while($nom = $images_dir->read ()){
     if($nom==$image_name_from_db){
      break; 
     }
}

<img src=<?php echo $name;?>  />

#

why you want to select image name from DB and search in dir ?
Idea : why you do not put the full path to your image in db then select it then use it, i think it well be more easy than your first idea !!!
hope this help.

0
if(!$v['mapImage'] == '')
                    {
                    //path folder name
                        echo '<img src="'.$v['mapPath'].'" width="600" height="450">';
                    }

another one is

Edited by malatamil: change

0
if(!$v['mapImage'] == '')
                    {
                        echo '<img src="path/path1/'.$v['mapImage'].'" width="600" height="450">';
                    }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.