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

[eluser]Redwhirl[/eluser]
I have a problem with my controller, here is the code

function index()
{
$this->load->model('welcome_model');
$data['rows'] = $this->welcome_model->getAll();
$this->load->view('welcome_message',$data);
}

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

Thanks
#2

[eluser]danmontgomery[/eluser]
Code:
<? php endforeach; ?>

should be

Code:
<?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:

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

[eluser]Redwhirl[/eluser]
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

Hubert
#4

[eluser]danmontgomery[/eluser]
Code:
echo '<strong>'.$r->prod_name.'</strong>';
#5

[eluser]Martín[/eluser]
Could you post your model? Maybe you have a problem there.

Regards.
#6

[eluser]Redwhirl[/eluser]
@noctrum

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

Great !!!

SOLVED




Theme © iAndrew 2016 - Forum software by © MyBB