Jump to content

Archived

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

deejay

searching multiple tables and fields

Recommended Posts

I realise that this subject has already many post on it, its just I cant seem to get my head around it :?

 

i have a table called \'cctvcity\' and inside that tables called \'products\', \'product_pages\', \'products_attributes\' and \'products_description\'. Say for example if I want to search for my keyword in the \'title\' or \'main_desc\' field of \'product_pages\' then what is wrong with this code.

 

<?php
\"SELECT *
         FROM cctvcity.products,cctvcity.product_pages,cctvcity.products_attributes,cctvcity.products_description
         WHERE product_pages.title LIKE \'%$search_keyword%\' OR product_pages.main_desc LIKE \'%$search_keyword%\' ORDER BY ASC \";
?>

 

thank you for any light you may be able to throw on this.

 

Deej

Share this post


Link to post
Share on other sites

Now ur quesry looks fine

 

U havent said much about the error or the output u get using the statement?

 

can u tell us more about it!!

Share this post


Link to post
Share on other sites

SELECT *

FROM cctvcity.products,cctvcity.product_pages,cctvcity.products_attributes,cctvcity.products_description

WHERE product_pages.title LIKE \'%$search_keyword%\' OR product_pages.main_desc LIKE \'%$search_keyword%\' ORDER BY

give ur field name here

ASC \";

Share this post


Link to post
Share on other sites

sorry,

 

it fails on \'\'error making query\'

 

$query = \"SELECT *

FROM cctvcity.products,cctvcity.product_pages,cctvcity.products_attributes,cctvcity.products_description

WHERE product_pages.title LIKE \'%$search_keyword%\' OR product_pages.main_desc LIKE \'%$search_keyword%\' ORDER BY ASC \";

 

 

$searchResults = mysql_query($query) or die(\'error making query\');

Share this post


Link to post
Share on other sites

See my posting

 

U havent given the filed name after

 

order by \"filed_name\" asc

Share this post


Link to post
Share on other sites

:oops: how much of an idiot do i feel.

 

 

cheers mate, sorted now.

Share this post


Link to post
Share on other sites

×

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.