Hi:
I try to build a search engine that search 2 tables as the same time. Is this possible because i try to look throught the board but i still can not find the answer.
Are there any reference any tutorial you can provide for me?
If this is impossible, Search Engine with radio button will be fine, but i do not how to do that. Are anybody has the source code for it?
If you have 2 of them,search engine searches 2 tables and search engine with radio button, please provide both.
here is the source code that i used; however, it is only searching 1 table. Are there anyway i can search more than 1 tables.
<?php
include ('connect.php');
$keywords = explode(" ", $search);
$query = "SELECT * FROM artist, lyric " .
"WHERE artist_name AND english_name AND song_title AND lyric_id LIKE '%".$keywords['0']."%'";
for ($i=1; $i<count($keywords); $i++) {
$query = $query." AND artist_name AND english_name AND song_title AND lyric_id LIKE '%".$keywords[$i]."%'";
}
$result = mysql_query($query) or die(mysql_error());
?>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<form method="GET" action="search2.php">
<b>Search:</b> <input type="text" name="search" size="20" />
<input type="submit" value="Search!" />
</form>
<?php
while($row = mysql_fetch_array($result))
{
$artist_id = $row[artist_id];
$artist_name = $row[artist_name];
$artist_name = $row[english_name];
$english_name = $row[english_name];
$song_title = $row[song_title];
$lyric_id = $row[lyric_id];
echo "<td style='border-bottom: 1px solid #000000;'>";
echo "<a href=\"show.php?artist_id=$artist_id\"><b>$english_name</b></a> - <a href=\"lyric.php?lyric_id=$lyric_id\">$song_title</a><br>";
}
?>
</html>
database structure
CREATE TABLE artist (
artist_id INT NOT NULL AUTO_INCREMENT,
artist_name VARCHAR(30) NOT NULL,
gender VARCHAR(30) NOT NULL,
PRIMARY KEY(artist_id)
);
CREATE TABLE lyric (
lyric_id INT NOT NULL AUTO_INCREMENT,
artist_id INT NOT NULL,
song_title VARCHAR(30) NOT NULL,
lyric TEXT NOT NULL,
PRIMARY KEY(lyric_id),
INDEX(artist_id)
);
If there is a radio button to change it, it will be okay, but i still have no idea how to use radio button.