My question is I want to display only one image from the multiple image uploaded in the home page and display all the images in another page.
The first part of the code is for the multiple upload which works perfectly, the second part of the code is for the selection. But the image is not displaying.
$file_name_all="";
for($i=0; $i<count($_FILES['image']['name']); $i++)
{
$tmpFilePath = $_FILES['image']['tmp_name'][$i];
if ($tmpFilePath != "")
{
$path = "upload/"; // create folder
$imagename = $_FILES['image']['name'][$i];
$size = $_FILES['image']['size'][$i];
list($txt, $ext) = explode(".", $imagename);
$file= time().substr(str_replace(" ", "_", $txt), 0);
$info = pathinfo($file);
$filename = $file.".".$ext;
if(move_uploaded_file($_FILES['image']['tmp_name'][$i], $path.$filename))
{
$file_name_all.=$filename."*";
}
$file="upload/" . $filename ;
}
}
$stmt = $this->conn->prepare('INSERT INTO help(name, email, phone, category, region, image, question, title, date)VALUES(:uname, :uemail, :uphone, :ucategory, :uregion, :uimage, :uquestion, :utitle, :udate)');
$stmt->bindParam(':uname', $name);
$stmt->bindParam(':utitle', $title);
$stmt->bindParam(':uemail', $email);
$stmt->bindParam(':uphone', $phone);
$stmt->bindParam(':ucategory', $category);
$stmt->bindParam(':uregion', $region);
$stmt->bindParam(':uimage', $file);
selection code.
public function needhelp(){
try{
$stmt = "SELECT help_id, name, image, question, date FROM help ORDER BY help_id DESC";
$result = $this->conn->query($stmt);
$result->execute();
return $row = $result->fetchAll();
}
catch(PDOException $e){
echo "query error" . $e->getMessage();
}
}