• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
use of array data in views

My array looks like this:
I am loading the view like this:
My view code looks like this:
Quote:Sort By: <select name="sorton">
<option value="perf-desc" &lt;?= if ($sort =="perf-desc") ? "selected='selected'" : "selected=''";?&gt; >Perf Desc</option>
Obviously I am doing something syntactically wrong to get this error:
Quote:Parse error: syntax error, unexpected T_IF in \system\application\views\testform.php on line 10

How should this be coded?


You're mixing the two ways to write conditional logic... Since you're using the ternary operator the if is implied, remove it and it the parser will stop complaining it's finding an IF when it wasn't supposed to.

That did it. Thanks so much.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.