Reputation: 403
I have this code which should search for pictured in mysql database, am not sure if it is working,
I want to get the images the user search for and post them in the html, can i do this?
Here is my code
<?php
require('connect.php');
if(isset($_POST['submit'])){
if(isset($_GET['go'])){
if(preg_match("/^[ a-zA-Z]+/", $_POST['name'])){
$name=$_POST['name'];
//connect to the database
//-query the database table
$sql="SELECT * FROM cards WHERE name LIKE '%$searchQuery'";
//-run the query against the mysql query function
$result=mysql_query($sql);
//-create while loop and loop through result set
while($row=mysql_fetch_array($result)){
$name = $row['name'];
$id = $row['id'];
}
}
else{
echo "<p>Please enter a search query</p>";
}
}
}
?>
Upvotes: 2
Views: 95
Reputation: 11310
To display the image [Where you have stored the image's path in db]
You shall just echo the coloumn with the image tag
echo "<img src =".$row['name'].">";
Note :
You should point the image the path where the image is stored in the files
Some thing like
echo "<img src ='assets/images/".$row['name']."'>"
Upvotes: 1