[eluser]brian88[/eluser]
I am using a variable in a if statement and it is not recognizing it as a normal variable. Just gives me an error saying unknown variable $i. any ideas?
Code:
<?php for ($i=1; $i<=$num_of_images ; $i++): ?>
// this $i does not work, unknown var
<?php if( $img->image.$i != 'nopic.jpg' ): ?>
heres the full code
controller
Code:
$data['images'] = $this->main_mod->getImages();
$data['num_of_images'] = 8;
// views
$data['content'] = 'main/post';
$this->load->view('templates/main', $data);
view
Code:
<?php foreach($images as $img): ?>
<p><?php echo $img->name; ?></p>
<?php for ($i=1; $i<=$num_of_images ; $i++): ?>
// this $i does not work, unknown var
<?php if( $img->image.$i != 'nopic.jpg' ): ?> // if an image was uploaded by user
<img src="<?php echo base_url('assets/images/').'/'.$img->image . $i; ?>" width="30" alt=""><br />
<?php endif; ?>
<?php endfor; ?>
<?php endforeach; // end ?>