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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.