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?

Recommended Answers

where is name of image

You should know. Where did you store it when uploading the image?

Jump to Post
$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 …

Jump to Post

All 5 Replies

where is name of image

You should know. Where did you store it when uploading the image?

$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.

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

another one is

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

Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.