现在我只能从数据库中只抓取一个特定的表。我有一些理论,我试过SELECT * FROM *
,但这根本不起作用。我很乐意给予任何帮助!这是我的代码:
<?php
if (isset($_POST['submit-search'])){
$conn = mysqli_connect("localhost","root","***","photos");
$search = mysqli_real_escape_string($conn, $_POST['search']);
$sql = 'SELECT * FROM images WHERE image LIKE "%'.$search.'%"';
$result = mysqli_query($conn, $sql);
$queryResult = mysqli_num_rows($result);
echo "<p>Found ".$queryResult." quote(s)</p>";
if ($queryResult > 0){
while($row = mysqli_fetch_assoc($result)){
echo "<a href='uploads/".$row['image']."' data-fancybox='quote'>";
echo "<img id='img_div' src='uploads/".$row['image']."'/>";
echo "</a>";
}
} else{
echo "There are no quotes matching your search.";
}
}
?>