Need some help setting a variable

I looking to set $offerings to $_POSt only if it is set.

'&offerings=' .$_POST['frmSearch']['offerings'][0]. "'

I want you guys to check if the script below is correct.

 isset($_POST['frmSearch']['offerings'][0]?'&offerings=' .$_REQUEST['frmSearch']['offerings'][0]. ':'';?>

Some how this index array is throwing an undefined index message when it is not set in the form. So I want that when being retrieve, only retrieve if it is set in the form to avoid this undefined index message.

 '&food_types= ' . $_POST['frmSearch']['food_types'][0]. if( isset($_POST['frmSearch']['offerings'][0])){'&offerings=' .$_POST['frmSearch']['offerings'][0]. } else{''}.  "'

I have also change to if and else statement since it is more effective. But still that set up above is throwing a big parse error message.

Help

Parse error: syntax error, unexpected ‘?’, expecting ‘,’ or ‘)’

It’s not correct :slight_smile:

I’d suggest to get rid if this ternary syntax.
It’s too complicated for you and will always trouble you .
Use regular condition: if (condition) {statement}

Thank you.