Re: Logic/method question...
| From: | Mike Frazer | Date: | Mon, 22 Oct 2001 18:38:16 +0000 |
| Subject: | Re: Logic/method question... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-71855@lists.php.net to get a copy of this message | ||
You could try using a separate file for configuration that uses arrays for
each catgeory:
$merchandise = new Array(
1,
2,
6,
23,
...
);
Then have it run a foreach loop:
foreach ($merchandise as $tempVar) { $queryConditions .= "AND code =
'$tempvar'"; }
You need to obviously work with it a little more, but this would be a very
helpful method to use. It would allow you to add a new code to the config
file without having to go digging really deep through your script. Just use
include() to get the config into your script.
Mike
"Jeff Lewis" <jeff@hyrum.net> wrote in message
news:004301c15b1d$b9f7ab80$76a1a8c0@LEWISJCIT...
It's not really, but kind of, a PHP question. I mean it is being written in
PHP :)
I am putting together a search feature for our classified ads and there are
about 4000 each day. Now I am bulding a query to search by newspaper, date,
and keywords. One last thing is categories.
Curious how others would handle this...on the search screen (and on the
site) we have broken down the classified codes into about 8-10 main groups
(stuff like Merchandise, Transportation, Services etc).
Now the problem is this: in the database, each ad goes in with it's class
code which matches up with the actual category. So instead of just
Merchandise we have sub categories like Christmas Trees.
There are close to 1500 class codeas and when I build this I need to allow
the user to select just one of the 8-10 codes and have the program return
everything.
Will I need to do something like:
if $selection="Merchandise" then
{
select all ads where code="2" AND code="5" AND code="123" AND
code="567"
etc etc
}
Jeff