通过页面上的图像路径和视图从phpmyadmin获取图像
在我的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">
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获取数组在这里返回什么吗?我的意思是把它打印出来