I have been trying for the past few days to try and figure out how to extract data from multiple tables, but I cannot say that I fully understood how this works. Anyway:)
What I'm trying to do is get the images stored in several tables using the search bar to determine the parameters, that is, the name of the artist (I know that saving the image in the database can cause a lot of problems, but this is an exercise for the university so I I can’t actually do much)
So to be specific now. I have 5 tables called animaldata, cardata, landscapedata, peopledata and otherdata. Each of the tables has the following fields: 1 id 2 artist_name 3 details 4 photos 5 phototype and 6 date. Where artist_name is the name of the registered person who uploads the image, and the details are the signature, the photograph is the blob element to save, and the phototype is the desired image type: P
So what I want to do when someone uses the search bar to search for an artist so that the code retrieves and displays all the images from all the tables that the artist has uploaded.
Here is the code that I use to extract data from 1 table, but I don’t know how to change it to look for other tables.
This is search.php
<?php
mysql_connect ("localhost","root","") or die (mysql_error());
mysql_select_db ("photo_album_db");
$term = $_POST['term'];
$sql = mysql_query("select * from animaldata where artist_name like '%$term%'");
while ($row = mysql_fetch_array($sql)){
echo $row['details'];
echo "</br>";
echo "<img src=getan.php?id=".$row['id']." width=250 height=200/>";
echo "</br>";
}
?>
The form of the search string is as follows:
<form action="search.php" method="post"><input type="text" name="term" /><input type="submit" name="search" value="Search" /></form>
, "", :):):)