onefastmustang wrote:
I am using that exact syntax.. I misspoke before.. POST does not work
either.. The reason I was using GET is that the client wants to be
able to use the back button on the browser without getting the PAGE
EXPIRED page..
my form looks like this..
<input type="checkbox" value= "1" name="roles[]" >
<input type="checkbox" value= "2" name="roles[]" >
The reciveing code looks like this..
$roles = $_GET[roles]. $_POST[roles];
if ($roles) {
$sqls = $sqls. " and profiles.role IN (";
foreach ($roles as $key => $value){
$sqls = $sqls. "$value,";
}
$sqls = substr("$sqls", 0 , -1);
$sqls .= ")";
}
Well, $roles won't be an array at this time - you did a string
concatenation on it.
If you're using GET method, use $_GET. If you're using $_POST, use
$_POST. You can also use $_REQUEST to handle either - but personally I
don't like that as well. But that's just my personal preference.
Also, if neither checkbox is checked, $roles will be empty.
A couple of changes:
$roles = isset($_GET['roles']) ? $_GET($roles) : null; // Note quotes!
if (isset($roles) { // Has one been set?
if (isarray($roles) { // Ensure it's an array
$sqls = $sqls. " and profiles.role IN (";
foreach ($roles as $key => $value){
$sqls = $sqls. "$value,";
}
$sqls = substr("$sqls", 0 , -1);
$sqls .= ")";
}
else { // Set but not an array
$sqls = $sqls . " and profiles.role = " . $roles . ")"
}
}
(note - not checked for syntax)
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================