Welcome Guest, Not a member yet? Register   Sign In
View file not being served from the controller
#11

[eluser]xwero[/eluser]
You can use it but the begin of the loop has to be
Code:
foreach ($array as $item):
But i think it only applies to short tags
#12

[eluser]dgriffter[/eluser]
I keep getting an error on this portion of code:


<div id="content">
&lt;?php if(!isset($bigimg)){?&gt;
<p>Test code here</p>
&lt;?
}
else {
foreach($getimg->result() as $row):?&gt;
<img src="/uploads/&lt;?=$row->userfile?&gt;"/>
&lt;?php endforeach;
}?&gt;
</div>


The logs give me a PHP Parse error: syntax error, unexpected T_ENDFOREACH in.... can you see where it's going wrong?
#13

[eluser]xwero[/eluser]
damn that looks messy. i would change it to
Code:
&lt;?php if(!isset($bigimg)){?&gt;
<p>Test code here</p>
&lt;?php  }else {
foreach($getimg->result() as $row){ ?&gt;
/uploads/&lt;?=$row->userfile?&gt;
&lt;?php } /* end foreach */ }?&gt;
But it doesn't make sense because if there is no image it shows a paragraph and if there is/are images it shows an url ???
#14

[eluser]gtech[/eluser]
I prefer to use the endforeach and the endif tags to keep things neat. try:

Code:
<div id="content">
    &lt;?php if(!isset($bigimg)):?&gt;    
        <p>Test code here</p>
    &lt;?php else:?&gt;
        &lt;?php foreach($getimg->result() as $row):?&gt;
            <img src="/uploads/&lt;?=$row->userfile?&gt;"/>
        &lt;?php endforeach;?&gt;
    &lt;?php endif;?&gt;
</div>

[edit] code above added ; to endif
#15

[eluser]dgriffter[/eluser]
Thank you for that - it works great now... Can I just ask about this last piece of code and then I'll try and wade through the rest myself....


&lt;?php
$num=0;
foreach($query3->result() as $fila){
if($num==0)
$prod= $fila->id;
$num=$num+1;
};?&gt;
&lt;?php foreach($query->result() as $row){?&gt;
<li>&lt;?=anchor('main/choosen/'.$row->idfamily.'/'.$prod.'/1', $row->familyname ,array('class' => 'sel'));?&gt;</li>
&lt;?php }?&gt;

It doesn't seem to be working...

Thank you once again,
Dgriffter
#16

[eluser]xwero[/eluser]
php5 iteration

You said the server was php4, that version hasn't got the possibility yet to use a foreach to loop through objects.




Theme © iAndrew 2016 - Forum software by © MyBB