Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 11-12-2005, 05:28 AM   #1
Foldin' For PCMech!
 
enhanced08's Avatar
 
Join Date: Jun 2003
Location: back home in McHenry MD
Posts: 1,657
Send a message via AIM to enhanced08 Send a message via MSN to enhanced08
PHP search wildcard?

I'm working with a database and have the option to select between 8ish different groups to search from. For example: CPU Speed, CPu Type, RAM, OS, etc. how would I set it up so that a user might select all items from a specific group? Like so he can select a 2.8 P4 and with any amount of ram or something.

Its like when your searching on a website and have a drop down menu and you can select "Any" or "All" from the menu and get everything. How do you do this?

thanks!
enhanced08 is offline   Reply With Quote
Old 11-12-2005, 07:03 AM   #2
Chop Chop
 
catacon's Avatar
 
Join Date: Jan 2005
Location: St. Louis, MO
Posts: 1,035
Send a message via AIM to catacon Send a message via Yahoo to catacon
What is the field type for each of the section? Like is the CPU TEXT and the amount of Ram INT? You could try to make them all TEXT, so numbers and letters can go into the field. Then tou should be able to have the "All" option. Are you just going to be displaying somewhere, or what?
catacon is offline   Reply With Quote
Old 11-12-2005, 07:10 AM   #3
Foldin' For PCMech!
 
enhanced08's Avatar
 
Join Date: Jun 2003
Location: back home in McHenry MD
Posts: 1,657
Send a message via AIM to enhanced08 Send a message via MSN to enhanced08
In the database or in the form? Everything is TEXT in the database. How do I use the "All" option? Yes, I want to have the data displayed on another page.
enhanced08 is offline   Reply With Quote
Old 11-12-2005, 08:03 AM   #4
Wx geek
 
blue60007's Avatar
 
Join Date: Aug 2005
Location: Indiana
Posts: 6,638
Can't you just include "All" like any other menu item?
__________________
"It is the way of man to make monsters and it is the nature of monsters to destroy their makers."
blue60007 is offline   Reply With Quote
Old 11-12-2005, 08:08 AM   #5
Foldin' For PCMech!
 
enhanced08's Avatar
 
Join Date: Jun 2003
Location: back home in McHenry MD
Posts: 1,657
Send a message via AIM to enhanced08 Send a message via MSN to enhanced08
Thats what I want to do, but what do I set the value to so that it will include everything rather than search for the term "All".
enhanced08 is offline   Reply With Quote
Old 11-12-2005, 08:12 AM   #6
Wx geek
 
blue60007's Avatar
 
Join Date: Aug 2005
Location: Indiana
Posts: 6,638
Oh...I think for MySQL DB's you want to use %
blue60007 is offline   Reply With Quote
Old 11-12-2005, 08:16 AM   #7
Foldin' For PCMech!
 
enhanced08's Avatar
 
Join Date: Jun 2003
Location: back home in McHenry MD
Posts: 1,657
Send a message via AIM to enhanced08 Send a message via MSN to enhanced08
Ok, thats what I finally figured out after about 2 hours on google, but I can't get it to work. I think its because the way I am calling it in.

This is how its setup. I have a page with drop down menus and each option on the menu is assigned to a string, or whatever its called in PHP (i'm very new to it), and then sent to a search page when the data is searched for and displayed on screen. I set it up so that it would display what its searching for so I could tell if the right data was being passed. It shows that it is searching for the item "%" and not its wildcard value.
enhanced08 is offline   Reply With Quote
Old 11-12-2005, 08:41 AM   #8
Wx geek
 
blue60007's Avatar
 
Join Date: Aug 2005
Location: Indiana
Posts: 6,638
OK, I think I see the problem. If you are setting All equal to "%" in say the variable $ram, then you do your query:

$query = "SELECT ram WHERE ram = '" . $ram ."';

Then what's happening is it's literally looking for '%'...

not sure how to go about fixing that, but I think that's what's happening
blue60007 is offline   Reply With Quote
Old 11-12-2005, 08:45 AM   #9
Foldin' For PCMech!
 
enhanced08's Avatar
 
Join Date: Jun 2003
Location: back home in McHenry MD
Posts: 1,657
Send a message via AIM to enhanced08 Send a message via MSN to enhanced08
from selection page:
Code:
select name="Sram"
option value=% selected - RAM AMT - option
from search page:
Code:
$ query = "SELECT * FROM WU2 WHERE ram LIKE '$Sram' && client LIKE '$Sclient' && speed LIKE '$Sspeed'""
thats my code and yes, thats whats hapeneing. its looking for "%" rather than the wildcard value of it.

EDIT: i had to remove a few "< and >" so the text would show rather than the code running

Last edited by enhanced08; 11-12-2005 at 08:50 AM.
enhanced08 is offline   Reply With Quote
Old 11-12-2005, 08:56 AM   #10
Wx geek
 
blue60007's Avatar
 
Join Date: Aug 2005
Location: Indiana
Posts: 6,638
Have you tried something like this:

$query = "SELECT ram WHERE ram = '" . $ram ."';

I'm not really an expert at this, so...
blue60007 is offline   Reply With Quote
Old 11-12-2005, 08:59 AM   #11
Foldin' For PCMech!
 
enhanced08's Avatar
 
Join Date: Jun 2003
Location: back home in McHenry MD
Posts: 1,657
Send a message via AIM to enhanced08 Send a message via MSN to enhanced08
nope, doesn't work...

should i keep option value=% or change it to something else?

EDIT: I know there is a way to do this because I have seen it done before as I'm sure you have as well.

Last edited by enhanced08; 11-12-2005 at 09:02 AM.
enhanced08 is offline   Reply With Quote
Old 11-12-2005, 06:29 PM   #12
Wx geek
 
blue60007's Avatar
 
Join Date: Aug 2005
Location: Indiana
Posts: 6,638
Have you tried searching by literally 'ram = %', and not using a variable?
blue60007 is offline   Reply With Quote
Old 11-13-2005, 11:14 AM   #13
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
You said you have everything in the database set as TEXT? The wildcard search probably will not work unless you are indexing the field. Change the field type to VARCHAR and it should work.
faulkner132 is offline   Reply With Quote
Old 11-14-2005, 10:56 AM   #14
Staff
Premium Member
 
mairving's Avatar
 
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
Need to modify things a bit.

PHP Code:
SELECT from database_tablename
WHERE ram like
="%$ram%" 
Example:
You are searching for the word 'them'. The above statement would find words like 'them', 'theme', 'anthem', if they existed in the field that you are searching.

Course pretty silly to have RAM as a text field when it is numeric.
__________________

Want to Make $$$$ with your Computer? No Risk! Simply press shift-4 four times in a row
mairving is offline   Reply With Quote
Old 11-15-2005, 02:51 AM   #15
Foldin' For PCMech!
 
enhanced08's Avatar
 
Join Date: Jun 2003
Location: back home in McHenry MD
Posts: 1,657
Send a message via AIM to enhanced08 Send a message via MSN to enhanced08
Ok, I got it to work, it turns out that I do have it set as VARCHAR rather than TEXT, sorry about that.

Thanks for the help guys, I hope your good at this stuff, cause I know I'll be back with more problems and questions! lol thanks!
enhanced08 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:00 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2