last day (15 days later) » 

9:27 AM
0
Q: Set time schedule in codeigniter

RoseI have a list of students and a common button Appointment Schedule. When i click the button set the time schedule for each student is inserted int db Now i set start time as 9 am . schedule appointment for all students in that table with 20 min time gap. controller function appointment_sche...

 
i need one clarification, on click of button once, you will fix appointment to all students??
 
yes...start time shows currect time format also end time.now its wrong
 
use strtotime() to add time to current time.
 
I want the start time 9 am
how to pass parameters in time() function..I want time as 09:00:00 am
 
check the answer below
did the answer worked for you??
 
9:27 AM
 
this is my out put now..i have only 2 rows that st time and time
 
2 rows in db??
 
for loop count only 2 now
 
what was count suposed to??
morethan 2?
 
9:32 AM
i want to set appointment time for 2 students
thats ok.
but my time format is wrong
 
for first row 9:00
fir second 9:20
for 3rd 9:40
so on
this is what you want rite??
 
no..first student-start time 9 am ,end time 9:20 am
second student start time 9:20 and end time 9:40 am
and so on
 
so u want current time
and +20 mins time??
 
start from 9 am
 
store in 24 hours format, i ll update my answer in some time
 
9:36 AM
u got it my suggetion?
 
ya i got ur point
 
ok
 
will get back with answer in some time
$time = strtotime("09:00");
for($i = 0; $i < 5; $i++){
$endTime = date("H:i", strtotime('+20 minutes', $time));
echo date("H:i", ($time)) ."======". $endTime."<br>" ;
$time = strtotime($endTime);

}
check that
its working fime
 
plz wait i will try
 
ya sure
by that time i ll update my answer
 
9:41 AM
totaly confused..plzz update i the answer
 
check now
 
now the out put echo is right but in db start time wrong
 
show db start time
 
i put ur updated answer show an error column name cant be null
 
i didnt get u
 
9:48 AM
replace $time?
$endTime = date("H:i", strtotime('+20 minutes', $time));
with $st_time
 
ya
replace that
 
some db error
Column 'end_time' cannot be null
 
replace $endTime with $end_time
i have taken my variables
replace with yours
 
ok..
09:00======09:20
09:20======09:40
got this way
 
its correct rite??
 
9:52 AM
how can i include seconds and am/pm
 
$time = strtotime("09:00 am");
for ($i = 0; $i < 15; $i++) {
$endTime = date("H:i:s a", strtotime('+20 minutes', $time));
echo date("H:i:s a", ($time)) . "======" . $endTime . "<br>";
$time = strtotime($endTime);
}
i have updates to hh:mm:ss am/pm
 
replaced variables
$st_time = strtotime("09:00 am");
for ($i = 0; $i < 15; $i++) {
$end_time = date("H:i:s a", strtotime('+20 minutes', $st_time));
echo date("H:i:s a", ($st_time)) . "======" . $end_time . "<br>";
$st_time = strtotime($end_time);
}
 
ok thank u so much for yur help ....
thank u very much
 
it worked perfectly??
 
ya..
 
9:58 AM
dont forget to upvote and acept the answer
 
sure
 
can i ask one more
 
When i click a common button for all students the table contain an id field other than AI id
how can i insert each student id at one button click
 
10:01 AM
can u show some code??
it ll be easy
 
if all students having buttons id will pass through that button
ok
<?
foreach($filter_students->result() as $detail)
{ ?>
<?php echo $detail->applicant_first_name;?>
<?}?>


<a href="<?echo base_url();?>home/appointment_schedule" class="btn green button_style" style="margin-left:22px;" title="Filter">Schedule Appointment</a>
this is my view page.
filter_students contain id and name..now i take to display name
 
your question is to store the appiont saperately for each student??
 
??
 
you want to have saperate button for every student??
 
no..
 
10:09 AM
then??
 
i have only one button for all
 
r u got it?
 
from 1 common button, what you want to do??
 
take all ids to the controller function then pass to the loop bt idont know is it worked right?
 
10:16 AM
but on what basis will you update?
 
thats my problm
 
if there is a condition to do, suppose i want to fix appoint for each students separately, i can take the id and update to db
 
hat condition?
 
what?
$filtered_students contain id
in the controller
 
10:21 AM
i have a small doubt
 
plzz say
 
why do you need id to uodate??
update*
 
dont know..i ask a suggetion
 
Any idea
 
10:27 AM
i think for this, we cant do
if tel me some condition, i can suggest you
 
i think tha..r u available after some time
 
can we take row() id inside the loop
 
u mean from db rite??
 
yes
 
10:33 AM
ya you cantake
$res = $this->db->get("sometable")->row();
echo $res->id;
 
how can i take in my controller
 
paste controller code
 
??
 
sorry
from model return $res->row();
here after collecting the return value
echo $var->id
 
function getFilterStudentsIds()
{
$this->db->select('applicant_id,applicant_first_name');
$this->db->from('student_application');
$this->db->where('filter_status',1) ;
$filter_student=$this->db->get()->row();
echo $filter_student->applicant_id;
// echo $this->db->last_query();
return $filter_student;
}
my modal
controller..??
$filtered_student_ids = $this->home_model->getFilterStudentsIds();
how to pass to my loop
 
10:48 AM
y ru echoing in model??
in controller
echo$filtered_student_ids->id;
 
Column 'applicant_id' cannot be null
echo$filtered_student_ids->applicant_id;
 
first try toecho.
see if sny error os coming..
 
echo$filtered_student_ids->applicant_id;
 
what r u getting??
 
i put the above code shows error
 
10:56 AM
what error
?
 
Column 'applicant_id' cannot be null
 
if u echo you r getting that??
i think ur trying to insert
to db
 
no
function getFilterStudentsIds()
{
$this->db->select('applicant_id,applicant_first_name');
$this->db->from('student_application');
$this->db->where('filter_status',1) ;
$filter_student=$this->db->get()->row();
return $filter_student;
}
 
this is model
show controller
 
put the above code in model
$filtered_student_ids = $this->home_model->getFilterStudentsIds();
echo$filtered_student_ids->applicant_id;
thats in the controller
 
10:59 AM
wait i ll check
 
how this pass to my for loop
 
what is echo printing??
 
i got the id 1(first student)
 
you want all student's id??
 
ya
 
11:07 AM
then in model it shud be result() instead of row()
row() will return only 1 row
result() will return all matching rows.
 
$filter_student=$this->db->get()->result();
rite?
whats the change in controller?
 
in controller
foreach($filtered_student_ids as $row) {
echo $row->applicant_id;//this ll print id's of each students matching your criteria
}
 
i know bt have afor loop
 
where??
ok*
o i got it
insode for()
if you want to use id,
echo $filtered_student_ids[$i]->applicant_id;
 
in the previus answer u check that controller where there is a for loop ,I wnt to pass this
 
11:17 AM
ya i saw
 
in this no need for foreach rite?
 
no need
 
$filtered_students = $this->home_model->insert_appointment_schedule(date("H:i:s a", ($st_time)),$end_time,$filtered_student_ids[$i]->applicant_id); ok?
 
ya i think its fine
 
i got it..i dont know how to thank u
Anyway thank u so much
 
11:23 AM
its working??
 
yes
 
glad i helped you:)
 
than u
i expect ur help in future
 
ya... No problem, you can ask me
 

  last day (15 days later) »