magus
magus

Reputation: 19

$_GET command not working

I have an issue.

echo CHtml::button('Sell It', array('submit' => array('mobile/create', array('id'=>$data->id))));

and after doing the above operation i'm getting the url to be

http://localhost/abhimir-mobile-d28927ecb74b/index.php/mobile/create?0%5Bid%5D=1

now im using the $_GET['id'] in the view of another controller.....how do i pass a variable from view of one contoller to view of another?

Upvotes: 1

Views: 236

Answers (3)

ldg
ldg

Reputation: 9402

The array for the path/route + data is a single array, it should be like this:

echo CHtml::button('Sell It', array('submit' => array('mobile/create','id'=>1)));

The way you have it is mangling the name/value pairs which is why it looks like that.

Upvotes: 2

markus
markus

Reputation: 40675

$_GET is not a command, it's an array! Once you've unserstood that, you should be able to understand your problem.

If you have a problem with getting values from an array, always look into your array with:

  • print_r(array) or
  • var_dump(array) or
  • even better the debugger!

Upvotes: 4

Jacek Kaniuk
Jacek Kaniuk

Reputation: 5229

create?id=1 and create?0%5Bid%5D=1 are not the same, try $_GET['0[id]'] or var_dump($_GET);

Upvotes: 6

Related Questions