Welcome Guest, Not a member yet? Register   Sign In
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.




Theme © iAndrew 2016 - Forum software by © MyBB