0

How can I retrieve resource_id from the url below?

index.php?option=com_ajax&module=booking_form&method=getBooking&format=json&Itemid=131&date=2016-02-04T00:00:00.000Z&end=1970-01-01T12:00:00.000Z&resource_id=43&resource_id=45&room=41&start=1970-01-01T10:00:00.000Z 

I've tried using the following code snippet

$jinput = JFactory::getApplication()->input $multiple_res = $jinput->getVar('resource_id',array(),'', 'ARRAY'); 
1
  • why are you passing 2 times resource id in your URL ? Commented Feb 2, 2016 at 7:15

2 Answers 2

1

You have to change your URL to:

index.php?option=com_ajax&module=booking_form&method=getBooking&format=json&Itemid=131&date=2016-02-04T00:00:00.000Z&end=1970-01-01T12:00:00.000Z&resource_id[]=43&resource_id[]=45&room=41&start=1970-01-01T10:00:00.000Z 

Otherwise it will only get last resource_id value (45).

And get array of both values

$resource = $jinput->get('resource_id', array(), 'ARRAY'); 

results in

Array ( [0] => 43 [1] => 45 ) 
1

You need to be using get, rather than getVar.

Also, resource_id appears to be an integer, not an array.

You can use the following:

$jinput = JFactory::getApplication()->input; $resource = $jinput->get('resource_id', '', 'INT'); 

or:

$jinput = JFactory::getApplication()->input; $resource = $jinput->getInt('resource_id', ''); 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.