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

#1
[eluser]pmonty[/eluser]
My array looks like this:
Quote:$formdata('sort'=>'perf-desc')
I am loading the view like this:
Quote:$this->load->view('testform',$formdata);
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>
</select>
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?

Paul

#2
[eluser]kgill[/eluser]
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.

#3
[eluser]pmonty[/eluser]
That did it. Thanks so much.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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