
Ken Bridges - 2009-07-14 19:43:15
Hello,
Using Example5Grid as a start and setting the $options array.
I've been trying to set the column value in defaultcols to a string that I read in so the selection is variable.
1)
If I use this code section it works fine, I get the expected results from the table I'm using. It returns all rows where user='Charles':
$options = array(
"defaultcols" => array("user" => 'Charles'),
"add_allowed" => false,
"delete_allowed" => false,
"editablecols" => array ()
);
2) If I replace the literal 'Charles' with a string $DDD it works fine also:
$DDD = "Charles";
$options = array(
"defaultcols" => array("user" => $DDD),
"add_allowed" => false,
"delete_allowed" => false,
"editablecols" => array ()
);
3) however if I attempt to set the string in a switch based on $_GET value I do not receive any rows:
$id = $_GET['info_id']; //selected name from form
switch ($id) {
case "Alvin": { $DDD = "Alvin"; break; }
case "Charles": { $DDD = "Charles"; break; }
case "Ken": { $DDD = "Ken"; break; }
default: { $DDD = "Harvey"; }
}
$options = array(
"defaultcols" => array("user" => $DDD),
"add_allowed" => false,
"delete_allowed" => false,
"editablecols" => array ()
);
The value in $id is being set. I've used isset() in other tests to verify.
Why can't I get the $DDD string to work inside other functions?