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');
  • why are you passing 2 times resource id in your URL ? – Nehal Feb 2 '16 at 7:15
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 )
| improve this answer | |
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', '');
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.