Welcome Guest, Not a member yet? Register   Sign In
Transformating Object
#1

[eluser]Unknown[/eluser]
I need somehow work with object in view diferently than classical foreach method.
I have 32 "forms" for scheduling driving school lessons and I need to fill the text field with value from the db. And So I cannot use native foreach printing method - because of the For loop. Thanks for help:-))

Heres Controller:
Code:
function dayview($year, $month, $day)
{
  
  
  $data['notes'] = $this->mycal_model->getdaynotes($year, $month, $day);
  $this -> load -> view('day_view', $data);
  
}
Here is model:
Code:
function getdaynotes($year, $month, $day)
{
  $q = $this->db->get_where('calendar', array('date' =>$year."-".$month."-".$day));
  return $q -> result();

}
Here is View: //many things missing, it is up to you, thanks:-)
Code:
<?php
echo ("<div class='left'>");
$time = new DateTime('0:0');
for ($i = 1; $i<=16; $i++){

$time->modify('+45 minutes');
$period = $time->format('H:i');

$text = array('id' => $i, 'rows' => '1', 'cols' => '40', 'name' => 'note',);
$date = array('class' => 'hidden','id' => 'date', 'value' => $date, 'name' => 'date', );
$notetime = array('class' => 'hidden', 'value' => $period, 'name' => 'time', );
$id = array('class' => 'hidden', 'value' => $i, 'name' => 'id', );
$submit = array('id' => 'submit', 'name' => 'submit');

echo ("<ul><li>");
echo form_open("mycal/noteadd");
echo form_input($date); //datum pro přidání
echo form_input($notetime);
echo form_input($id);
echo form_label($period, 'text');
echo form_textarea($text);
echo form_submit($submit, "+");
echo form_close();
echo ("</li></ul>");
}
echo ("</div>");
}
?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB