Jump to content

SEARCH 3 TABLES


kagster

Recommended Posts

Hi all,

 

I try to make a search engine that will search on three tables and with multiple fields. Something like this:

 

<form action="search_results.php" method="post" name="findBook">

<p><label>Book title:</label><input type="text" name="BtName" class="field" size="20" /></p>

<p><label>Author:</label><input type="text" name="AuthorName" class="field" size="20"/></p>

<p><label>Publisher:</label><input type="text" name="PubName" class="field" size="20"/></p>

<p class="btn"><input type="submit" name="submit" value="Search.." /></p>

<input type="hidden" name="submitted" value="TRUE" />

</form>

 

And this is the three tables that form will search:

 

-----------------------------------

BOOKTITLE

BtId (Primary Key)

BtName

PubId (Foreign Key)

Value

-----------------------------------

 

-----------------------------------

AUTHOR

AuthorId (Primary Key)

AuthorName

-----------------------------------

 

-----------------------------------

PUBLISHER

PubId (Primary Key)

PubName

PubAddress

----------------------------------

I dont know how can make this select.  The user needs to be able to search Book Title, Author & Publisher.

 

Can anyone help me?

__________________

 

Link to comment
https://forums.phpfreaks.com/topic/162480-search-3-tables/
Share on other sites

Thank you for your reply.

 

I have tried this but it doesnt work

 

$query = "SELECT * t.BtName, a.AuthorName, p.PubName

FROM author

AS a

INNER JOIN authorship

AS i USING (AuthorId)

INNER JOIN BookTitle

AS t USING (BtId)

INNER JOIN publisher

AS p USING (PubId)

WHERE a.AuthorName LIKE '%".$_POST["AuthorName"]."%' AND p.PubName LIKE '%".$_POST["PubName"]."%' AND t.BtName LIKE '%".$_POST["BtName"]."%'";

 

Any idea where I am going wrong?

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/162480-search-3-tables/#findComment-857637
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.