this is my first question after being an avid reader of this site for a while now.
I have a php script that queries my database, and inside of that I have an if statement to allow only certain categories to show up in results.
I am building a script that will allow people to query my database, the script and service will be free, but I would like to be able to open up certain categories for searching by charging a really small fee just to help with server costs. And the best way I can think of doing this is above, by allowing them to purchase a file, placing that file in a certain folder, and have the script automatically know its there and open up a category. Ive never done anything like this before.
Basically the if statement goes like this:
if ($cat == 'Apple' || $cat == 'Orange'){
$returnval = $1 . "|" . $2 . "|" . $3 . "|" . $cat;
}
$1 $2 $3 $cat being what I queried.
My question is:
How can I make this if statement dynamic, by reading unknown files located in a directory? Say if each file inside of it $cat=='Apple'
and after each file read a ||
was placed after it unless the last file found.
What kind of php code would read a directory, then read all contents, making sure it was formatted as $cat=='Apple'
otherwise ignore, placing ||
at the end of contents that match that format, adding the contents to a string, placing it into that if statement above?
I think Im explaining what I would like to learn how to do right, but maybe there is another way.
The reason I want to do this, is because I would like to add functionality to a script I made, based on files located in a certain folder, each file adding functionality just by being in that directory.
Is this possible? Or is there maybe a better way?