Welcome Guest, Not a member yet? Register   Sign In
What is the correct way to display database information in my view?
#1

[eluser]johnnyForums[/eluser]
I can display it with <?=$row->product_id?> but I wanted to know if there were any helpers so that I didn't do stuff like:

foreach(...)
<ul>
<li><span id='product_id'>&lt;?=$row->product_id?&gt;</span></li>
...


I can do this but didn't know if it was the correct CodeIgniter way to do things.
#2

[eluser]Dam1an[/eluser]
The thing is, everyone wants the way it's output to be differant, so having a generic function which takes a database result and outputs it makes no sense.
There are function in the URl helper which make lists given arrays, which might be half of what you want
#3

[eluser]johnnyForums[/eluser]
[quote author="Dam1an" date="1249084675"]The thing is, everyone wants the way it's output to be differant, so having a generic function which takes a database result and outputs it makes no sense.
There are function in the URl helper which make lists given arrays, which might be half of what you want[/quote]

Then I am doing it in an acceptable way with my example, right?
#4

[eluser]Dam1an[/eluser]
Yeah, apart from the fact you're going to have the same ID repeated in the loop, which is bad
#5

[eluser]Kami_[/eluser]
You should avoid the short tags as well.

They are deprecated since PHP 5.3 (I know CodeIgniter offers short-tag rewriting but this probably adds just unnecessary overhead).
#6

[eluser]Dam1an[/eluser]
[quote author="Kami_" date="1249089261"]You should avoid the short tags as well.

They are deprecated since PHP 5.3[/quote]

Sad Yes I know I'm lazy for using them as well (but only in views)
#7

[eluser]johnnyForums[/eluser]
[quote author="Kami_" date="1249089261"]You should avoid the short tags as well.

They are deprecated since PHP 5.3 (I know CodeIgniter offers short-tag rewriting but this probably adds just unnecessary overhead).[/quote]

What should I use for 5.3?
#8

[eluser]Dam1an[/eluser]
The standard syntax
Code:
&lt;?php echo $var;?&gt;
istead of
&lt;?=$var?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB