Welcome Guest, Not a member yet? Register   Sign In
[SOLVED]Endforeach error and data viewing not appearing

I have a problem with my controller, here is the code

function index()
$data['rows'] = $this->welcome_model->getAll();

Nothing appears in my view, but if I make a print_r($data), the data appears.

Now in my view I have another problem, I have this code

<?php foreach($rows as $r) : ?>
<?php echo $r->prod_name; ?>
<?php echo $r->nb_tickets_sold; ?>
<? php endforeach; ?>

and when I run it, I get this error :
Parse error: syntax error, unexpected $end in C:\WampServer\www\CodeIgniter\Project_R\application\views\welcome_message.php on line 58

I have checked the syntax seems to be right.

A helping hand would be appreciated


<? php endforeach; ?>

should be

<?php endforeach; ?>

Although I don't really see the purpose of opening and closing php tags on 4 consecutive lines, or using endforeach at all:

<?php foreach($rows as $r) {
    echo $r->prod_name;
    echo $r->nb_tickets_sold;
} ?>

Thank you for this real fast help :d

I use for lines, because I am following a video I have seen from Tuts.com, and I will have to add some bolding when echoing the data

Thanks again


echo '<strong>'.$r->prod_name.'</strong>';

Could you post your model? Maybe you have a problem there.



Thanks a lot you solved everything in less then 2 minutes Smile

Great !!!


Theme © iAndrew 2016 - Forum software by © MyBB