Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

hi using php but having problem with search results

Guest
Jul 14, 2007 Jul 14, 2007

Copy link to clipboard

Copied

Hi my search results are working except for a very important part of only showing those that are active, set by admin.
It is showing results event if they are inactive.
My default in mysql is set to inactive and in edit I change to active.
This is what my search is:
TOPICS
Server side applications

Views

389
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jul 14, 2007 Jul 14, 2007
jjjhbj111 wrote:
> Hi my search results are working except for a very important part of only
> showing those that are active, set by admin.
> It is showing results event if they are inactive.

Rewrite the WHERE clause like this:

WHERE listingf.status = 'active' AND
(listingf.classbusinessname LIKE '%SearchString%'
OR listingf.inv_addr1 LIKE '%SearchString%'
OR listingf.classcatid LIKE '%SearchString%'
OR listingf.categorytype LIKE '%SearchString%'
OR listingf.inv_state LIKE '%SearchString%'
OR...

Votes

Translate
LEGEND ,
Jul 14, 2007 Jul 14, 2007

Copy link to clipboard

Copied

jjjhbj111 wrote:
> Hi my search results are working except for a very important part of only
> showing those that are active, set by admin.
> It is showing results event if they are inactive.

Rewrite the WHERE clause like this:

WHERE listingf.status = 'active' AND
(listingf.classbusinessname LIKE '%SearchString%'
OR listingf.inv_addr1 LIKE '%SearchString%'
OR listingf.classcatid LIKE '%SearchString%'
OR listingf.categorytype LIKE '%SearchString%'
OR listingf.inv_state LIKE '%SearchString%'
OR listingf.inv_addr2 LIKE '%SearchString%'
OR listingf.tel LIKE '%SearchString%')

Notice that the section after AND is enclosed in parentheses.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 14, 2007 Jul 14, 2007

Copy link to clipboard

Copied

Thank you so much David, you are sooo cool!
Switching around sometimes I forget to try that. I was starting to think of really complex recordsets. Y ou have saved me writing a whole lot of gibberish.
I did have the parenthesis in the beginning when I was using an inner join but removed it when I thought I didn't need it.
Something more to learn about.
Thanks again!!

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 15, 2007 Jul 15, 2007

Copy link to clipboard

Copied

jjjhbj111 wrote:
> Thank you so much David, you are sooo cool!
> Switching around sometimes I forget to try that. I was starting to think of
> really complex recordsets.

Glad to have sorted it so quickly. Sometimes, the simple solution is all
you need, but it often takes another pair of eyes to spot it.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 27, 2007 Jul 27, 2007

Copy link to clipboard

Copied

Hi just a quick question even though this is solved.
With the results page I am wanting to show the actual name instead of the foreign key.
What I mean is the inv_state is a foreign key but I am wanting to show the inv_statename.
I am wondering your thoughts as to keep the query the same include the inv_state table.
Thanks very much for your advice here it has been great...

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 27, 2007 Jul 27, 2007

Copy link to clipboard

Copied

jjjhbj111 wrote:
> What I mean is the inv_state is a foreign key but I am wanting to show the
> inv_statename.

To do that, you need to list all the columns that you want to retrieve
instead of using *. Then add inv_statename and the the name of the table
that it resides in.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 27, 2007 Jul 27, 2007

Copy link to clipboard

Copied

LATEST
thanks I thought so...

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines