Jump to content

Non php person needs help


dlsweb

Recommended Posts

Hi
This non php person would sure appreciate some help.
My site has a simple search box.
Upon searching for a keyword, it returns listings which match 1 of 10 keywords included in that specific listing- skey.
$query .= " and keywords like '%$skey%' and category like '%Mycategory%'";

I would like to also have the "bname" field checked for the specific keyword and included in the listings returned.
Not knowing php at all, I tried this
$query .= " and keywords like '%$skey%' or '%bname%' and category like '%Mycategory%'";

and
$query .= " and keywords like '%$skey%' or '%$bname%' and category like '%Mycategory%'";
which did not work.

A little help with correct code would be great.
Tks, Larry

Link to comment
Share on other sites

It may sound right when you say it in English but in code one must repeat each condition completely and NOT make the assumption that you do when you speak it.

 

 and (keywords like '%$skey%' or keywords like '%$bname%') and category like '%Mycategory%'";

 

(Note the set of parens too)

 

PS - this is not PHP btw - it is sql

Link to comment
Share on other sites

thanks much but did not return bname listings

and when I tried

$query .= " and keywords like '%$bname%' and category like '%Mycategory%'";

rather than

$query .= " and keywords like '%$skey%' and category like '%Mycategory%'";

it did not work either

I guess I will have to hire someone to do

tks

Link to comment
Share on other sites

I guess I will have to hire someone to do

 

Definitely an option and maybe your best, but if so, you might need to give someone access to your server which is never great.

 

Before doing so, you might wish to try some quick checks.  Do what ginerjm recommended, and then echo the query before PHP tries to execute it and post the query.  Or better yet, if you have access to your database, directly insert the query and see your response.

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.