Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过页面上的图像路径和视图从phpmyadmin获取图像_Php_Image_Path - Fatal编程技术网

通过页面上的图像路径和视图从phpmyadmin获取图像

通过页面上的图像路径和视图从phpmyadmin获取图像,php,image,path,Php,Image,Path,在我的phpmyadmin数据库中,我有一个名为rooms的表,有两列。第1列命名为room name并包含值:bookstore、foodcourt等。第2列命名为images并包含图像路径:/image/bookstore.jpg、/image/foodcourt.jpg等。 form.php包含用户输入,如bookstore、foodcourt等,提交到image.php <form name="form" method="POST" action="image.php">

在我的phpmyadmin数据库中,我有一个名为
rooms
的表,有两列。第1列命名为
room name
并包含值:
bookstore、foodcourt等。
第2列命名为
images
并包含图像路径:
/image/bookstore.jpg、/image/foodcourt.jpg等。

form.php包含用户输入,如
bookstore、foodcourt等
,提交到
image.php

<form name="form" method="POST" action="image.php">
    <fieldset>
        <p>Where are you trying to go? </p>
        <input type="text" name="mapinput" id="mapinput">
<br />
<br />
<input type="submit" name="submit" value="Submit">
</fieldset>
</form>

你想去哪里



image.php应将用户输入与数据库图像路径匹配,并根据用户输入回显图像

<?php
$conn=mysqli_connect("localhost","xxx","xxx","Capstone");
if (mysqli_connect_errno())
{
echo "Connect failed: " . mysqli_connect_error();
exit();
}

if (isset($_POST['mapinput'])) //mapinput is the user input from the form
{
      $map = $_POST['mapinput']; //user input is assigned variable $map
      $sql = "SELECT images FROM rooms WHERE room name=$map"; //selecting column images from table rooms where room name = user input ($map)
      $result = mysqli_query($conn,$sql);

while($row = mysql_fetch_array($result))
  {
    echo  "<img src = 'images" . $row['images'] . "' />"  //images is the column name that holds the image path
  }

}

mysqli_close($conn);

?>


在浏览时,它不会从关联的数据库映像路径发布任何映像。欢迎任何帮助,谢谢。

这似乎是路径问题。最好的办法是打开一只萤火虫。尝试检查损坏的图像。您将能够了解路径的错误。一旦出现问题,请在$row['images']之前添加正确的URL

尝试将完整url
用单引号括起$map。“从room name='$map'@meda的房间中选择图像这些图像只存储在/var/www/html/imagesI文件夹中。如果你使用Ubuntu,这与权限有关。”。你能告诉我们mysql获取数组在这里返回什么吗?我的意思是把它打印出来