0

I have three tables:

collections
[clientID][isbn]

books
[title][isbn][author]

clients
[cliendID][firstName][lastName]

I am making a seach functon on php. The function will search the clientID and display the name (from the clients table) and what book that client has (fro collections table). What should I do for the query?

$query = "select * from database.collections where clientID like '%".$searchterm."%'";

This is what I have right now. It's able to display the entered clientID and the ISBNs.

Edited by chuyauchi

2
Contributors
1
Reply
3
Views
4 Years
Discussion Span
Last Post by LastMitch
0

@chuyauchi

This is what I have right now. It's able to display the entered clientID and the ISBNs.

You should have post this in PHP section rather than database. The reason why is that you didn't give much detail how your seach functon on php works.

Base on the query you provided:

$query = "select * from database.collections where clientID like '%".$searchterm."%'";

I came up with this:

$sql="SELECT cliendID.collections, cliendID.clients, isbn.collections, isbn.books, firstName, lastName, title, author FROM database.collections, database.books, database.clients WHERE cliendID.collections = cliendID.clients LIKE '%".$searchterm."%' AND isbn.collections = isbn.books LIKE '%".$searchterm."%' AND firstName LIKE '%".$searchterm."%' OR lastName LIKE '%".$searchterm."%' OR title LIKE '%".$searchterm."%' OR author LIKE '%".$searchterm."%'"; 

I don't have a db to test it out.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.