Tony Pearce
asked on
PHP create a wildcard string if GET empty
Hi,
I have this chunk of PHP that I needed to create a wildcard % to be used in a query if no $_GET was found:
Any thoughts
Thanks
Tony
I have this chunk of PHP that I needed to create a wildcard % to be used in a query if no $_GET was found:
<?php
if (!isset($_GET["Sub_Category"]) || empty($_GET["Sub_Category"])) {
$scat = '%';
} else {
$scat = ($_GET['Sub_Category']);
}
?>
Any thoughts
Thanks
Tony
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What is the question? The code posted here will set $scat to be a string of length=1 and content=% if the URL does not have the Sub_Category argument. Is that what you want?
ASKER
perfect despite my bad question!!
Just a thought.. You might want to leave the questions open a little longer and maybe give a little more expository content with the question. For example, I sense that you might be wanting to use the $scat variable in a data base query (this is a common design pattern). Before you do that you might want to post a question here about something like, "What are the well-known best security practices that can help me keep my data base from getting destroyed or stolen by hackers?"