PHP Classes

Cannot set defaultcols with string value

Recommend this page to a friend!

      DrasticTools  >  All threads  >  Cannot set defaultcols with string value  >  (Un) Subscribe thread alerts  
Subject:Cannot set defaultcols with string value
Summary:Not getting results when trying to set defaultcols in $options
Messages:2
Author:Ken Bridges
Date:2009-07-14 19:43:15
Update:2009-07-14 20:30:05
 

  1. Cannot set defaultcols with string value   Reply   Report abuse  
Picture of Ken Bridges 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?



  2. Re: Cannot set defaultcols with string value   Reply   Report abuse  
Picture of dd dd - 2009-07-14 20:30:05 - In reply to message 1 from Ken Bridges
Hi Ken,

This does not work because the javascript calls the php file automaically and the URL parameters are generated by the javascript and your variable does not come along.
Use the "addparams" option instead and follow the way parameters are passed to the php code as in examplegrid9 on

drasticdata.nl


Hope this helps,

regards,

DrasticData