Welcome Guest, Not a member yet? Register   Sign In
simple form_checkbox with database
#1

[eluser]cyberizal[/eluser]
i want to load simple form_checkbox with data from column 'name' loaded from table student_name.

the data should read from model and the view will echo form_checkbox

assume in my table student_name the few data like john, julia,joseph, jenny, joe.
===================

its simple to loop php code in my view, but i dont want to do that..

thanks guys
#2

[eluser]Dam1an[/eluser]
Assuming I understand correctly, you're trying to avoid
Code:
foreach($users as $user) {
  echo form_checkbox($user->name, '', true/false);
}

why?
#3

[eluser]cyberizal[/eluser]
i think, i want my view to be clean as i can, i was a procedurel php guy and i hate OOP. but this CI makes switching from procedurel to OOP really at ease. and when i see what CI can offer, so i want to use and maximise it. so meaning, i want my view file done by other people(web designer for example), so my code will be identified easily.
#4

[eluser]cyberizal[/eluser]
below is my array pass to view

Array ( [AE001] => Mohd Shahrizzal Bin Amdan [AE002] => Wayne Rooney [AE003] => Dimitar Berbatov [AE004] => Julia Roberts )

but when try to do your for each, ive got

Severity: Notice

Message: Trying to get property of non-object

thanks..
#5

[eluser]Dam1an[/eluser]
You're robably not going to get much more legible then the above code example, although you could do it in a single line using an array map
Alternativly, if other people are making the views, you could try using the templates?




Theme © iAndrew 2016 - Forum software by © MyBB