I created 12 different functions and 12 different ctp files for showing the value from the database into my webpage using 12 months 12 Tabs LIKE January ... December . I want to show three top values from each month. As per cakephp we created different function for different CTP files. Like for January i created one function name January and created one CTP file name january.ctp and like for rest of 11 months i created different different functions using months name with same month wise CTP files.Just the value of the month($month) is different in each function , Is there is any way to write one function and sending variable into the 12 ctp files. How can i make my code more efficient, i added my code below
<?php
namespace App\Controller;
use Cake\Core\Configure;
use App\Controller\AppController;
use Cake\ORM\TableRegistry;
public function january()
{
$userDetails=Configure::read('userdetails');
$profile=Configure::read('profile');
$this->loadModel('Users');
$usersID = $this->Auth->user('id');
$profileImageShow=$this->Users->getUploadPath($usersID);
$categoryTable=TableRegistry::getTableLocator()->get('categories');
$results=$categoryTable->find("all")->toList();
$votes;
$month = 01;
$year=date("Y");
$categoriesArray;
foreach($results as $result)
{
$votesCount=$this->Sjvotes->find("all",[
'conditions'=>['month'=> $month,'year'=>$year,'category_id'=>$result->id]])->select(['count' => $this->Sjvotes->find()->func()->count('*')])->group(['user_id','category_id'])->order(['count'=>'desc'])->limit(2)->toList();
$categoriesArray[]=$result->id;
$temp=0;
foreach($votesCount as $key => $count)
{
if($temp!=$count->count)
{
$userVotes=$this->Sjvotes->find("all", ['conditions'=>['year'=>$year,'category_id'=>$result->id]])->
select(['count' => $this->Sjvotes->find()->func()->count('*'), 'category_id','user_id','fname'=>'Users.firstname','lname'=>'Users.lastname', 'profile_image'=>'Users.profile_image'])
->contain(['Users'])
->group(['user_id','category_id'])
->having(['count'=>$count->count])
->order(['count'=>'desc'])
->toList();
$temp=$count->count;
if($key==0)
{
$class="gold";
}else
if($key==1)
{
$class="silver";
}else
{
$class="bronz";
}
$votes[$result->id][$class]=$userVotes;
}
}
}
$voteToppers=$this->Sjvotes->find("all", ['conditions'=>['year'=>$year,'category_id in ' =>$categoriesArray]])->
select(['count' => $this->Sjvotes->find()->func()->count('*'), 'category_id','user_id','fname'=>'Users.firstname','lname'=>'Users.lastname', 'profile_image'=>'Users.profile_image'])
->contain(['Users'])
->group(['user_id'])
->order(['count'=>'desc'])
->toList();
$temp=0;
$changes=0;
foreach($voteToppers as $key => $topper)
{
if($temp!=$topper->count)
{
if($changes==0)
{
$class="gold";
}else
if($changes==1)
{
$class="silver";
}else
{
$class="bronz";
}
$temp=$topper->count;
$changes++;
}
if($changes>3)
{
break;
}
$topUsers[$class][]=$topper;
}
$this->set(compact("results"));
$this->set(compact("votes"));
$this->set(compact(["topUsers", "userDetails", "profile"]));
}
//For February
public function february()
{
$userDetails=Configure::read('userdetails');
$profile=Configure::read('profile');
$this->loadModel('Users');
$usersID = $this->Auth->user('id');
$profileImageShow=$this->Users->getUploadPath($usersID);
$categoryTable=TableRegistry::getTableLocator()->get('categories');
$results=$categoryTable->find("all")->toList();
$votes;
$month = 02;
$year=date("Y");
$categoriesArray;
foreach($results as $result)
{
$votesCount=$this->Sjvotes->find("all",[
'conditions'=>['month'=> $month,'year'=>$year,'category_id'=>$result->id]])->select(['count' => $this->Sjvotes->find()->func()->count('*')])->group(['user_id','category_id'])->order(['count'=>'desc'])->limit(2)->toList();
$categoriesArray[]=$result->id;
$temp=0;
foreach($votesCount as $key => $count)
{
if($temp!=$count->count)
{
$userVotes=$this->Sjvotes->find("all", ['conditions'=>['month'=>$month,'year'=>$year,'category_id'=>$result->id]])->
select(['count' => $this->Sjvotes->find()->func()->count('*'), 'category_id','user_id','fname'=>'Users.firstname','lname'=>'Users.lastname', 'profile_image'=>'Users.profile_image'])
->contain(['Users'])
->group(['user_id','category_id'])
->having(['count'=>$count->count])
->order(['count'=>'desc'])
->toList();
$temp=$count->count;
if($key==0)
{
$class="gold";
}else
if($key==1)
{
$class="silver";
}else
{
$class="bronz";
}
$votes[$result->id][$class]=$userVotes;
}
}
}
$voteToppers=$this->Sjvotes->find("all", ['conditions'=>['month'=>$month,'year'=>$year,'category_id in ' =>$categoriesArray]])->
select(['count' => $this->Sjvotes->find()->func()->count('*'), 'category_id','user_id','fname'=>'Users.firstname','lname'=>'Users.lastname', 'profile_image'=>'Users.profile_image'])
->contain(['Users'])
->group(['user_id'])
->order(['count'=>'desc'])
->toList();
$temp=0;
$changes=0;
foreach($voteToppers as $key => $topper)
{
if($temp!=$topper->count)
{
if($changes==0)
{
$class="gold";
}else
if($changes==1)
{
$class="silver";
}else
{
$class="bronz";
}
$temp=$topper->count;
$changes++;
}
if($changes>3)
{
break;
}
$topUsers[$class][]=$topper;
}
$this->set(compact("results"));
$this->set(compact("votes"));
$this->set(compact(["topUsers", "userDetails", "profile"]));
}
//March
public function march()
{
$userDetails=Configure::read('userdetails');
$profile=Configure::read('profile');
$this->loadModel('Users');
$usersID = $this->Auth->user('id');
$profileImageShow=$this->Users->getUploadPath($usersID);
$categoryTable=TableRegistry::getTableLocator()->get('categories');
$results=$categoryTable->find("all")->toList();
$votes;
$month = 03;
$year=date("Y");
$categoriesArray;
foreach($results as $result)
{
$votesCount=$this->Sjvotes->find("all",[
'conditions'=>['month'=> $month,'year'=>$year,'category_id'=>$result->id]])->select(['count' => $this->Sjvotes->find()->func()->count('*')])->group(['user_id','category_id'])->order(['count'=>'desc'])->limit(2)->toList();
$categoriesArray[]=$result->id;
$temp=0;
foreach($votesCount as $key => $count)
{
if($temp!=$count->count)
{
$userVotes=$this->Sjvotes->find("all", ['conditions'=>['month'=>$month,'year'=>$year,'category_id'=>$result->id]])->
select(['count' => $this->Sjvotes->find()->func()->count('*'), 'category_id','user_id','fname'=>'Users.firstname','lname'=>'Users.lastname', 'profile_image'=>'Users.profile_image'])
->contain(['Users'])
->group(['user_id','category_id'])
->having(['count'=>$count->count])
->order(['count'=>'desc'])
->toList();
$temp=$count->count;
if($key==0)
{
$class="gold";
}else
if($key==1)
{
$class="silver";
}else
{
$class="bronz";
}
$votes[$result->id][$class]=$userVotes;
}
}
}
$voteToppers=$this->Sjvotes->find("all", ['conditions'=>['month'=>$month,'year'=>$year,'category_id in ' =>$categoriesArray]])->
select(['count' => $this->Sjvotes->find()->func()->count('*'), 'category_id','user_id','fname'=>'Users.firstname','lname'=>'Users.lastname','profile_image'=>'Users.profile_image'])
->contain(['Users'])
->group(['user_id'])
->order(['count'=>'desc'])
->toList();
$temp=0;
$changes=0;
foreach($voteToppers as $key => $topper)
{
if($temp!=$topper->count)
{
if($changes==0)
{
$class="gold";
}else
if($changes==1)
{
$class="silver";
}else
{
$class="bronz";
}
$temp=$topper->count;
$changes++;
}
if($changes>3)
{
break;
}
$topUsers[$class][]=$topper;
}
$this->set(compact("results"));
$this->set(compact("votes"));
$this->set(compact(["topUsers", "userDetails", "profile"]));
}
//april
One thing you can do is. Get the current month and then check the current month, then send to that month ctp file according to the current month. Like this -
$month = date('M');
if ($month == 'Mar') {
$this->render('/march');
}
if ($month == 'Jan'){
$this->render('/jan');
}
The only difference is the value of the $month variable?
public function january() {
return $this->_month(1, 'January');
}
public function february() {
return $this->_month(2, 'February');
}
// etc...
protected function _month($month, $monthName) {
// Existing implementation of each month's function here,
// except without initializing the $month variable
$this->set(compact('results', 'votes', 'topUsers', 'userDetails', 'profile', 'month', 'monthName'));
$this->render('month');
}
And rename january.ctp to month.ctp, and you'll have the $month and $monthName variables available there now to tell you what month it's for.
Related
I am creating an .ics file for outlook calendar, It is working properly when i pass start_time and end_time of event to it but i'm not able to work on all day event. Should i pass 000000 to time for eg. 20190703T000000.
I am passing date time of event like this :
$eventArray[]=array('description'=>'Event','dtstart' => $eventList->date.'T'.$eventList->start_time,'dtend' => $eventList->date.'T'.$eventList->end_time);
Library for icsevent:
<?php
Class Icsevents {
const DT_FORMAT = 'Ymd\THis'; //define date format here
public $events;
public function __construct($events) {
if(count($events)>0) {
for($p=0;$p<=count($events)-1;$p++) {
foreach($events[$p] as $key => $val) {
$events[$p][$key] = $this->sanitize_val($val, $key);
}
}
}
$this->events=$events;
}
private function sanitize_val($val, $key = false) {
switch($key) {
case 'dtend':
case 'dtstamp':
case 'dtstart':
$val = $this->format_timestamp($val);
break;
default:
$val = $this->escape_string($val);
}
return $val;
}
private function format_timestamp($timestamp) {
$dt = new DateTime($timestamp);
return $dt->format(self::DT_FORMAT);
}
private function escape_string($str) {
return preg_replace('/([,;])/','$1', $str);
}
function prepare() {
$cp=array();
if(count($this->events)>0) {
$cp[]= 'BEGIN:VCALENDAR';
$cp[]= 'VERSION:2.0';
$cp[]= 'PRODID:-//hacksw/handcal//NONSGML v1.0//EN//b3';
$cp[]= 'CALSCALE:GREGORIAN';
for($p=0;$p<=count($this->events)-1;$p++) {
$cp[]='BEGIN:VEVENT';
foreach($this->events[$p] as $key => $val) {
if ( $key === 'url' ) {
$cp[]= 'URL;VALUE=URI:'.$val;
} elseif ( $key === 'alarm' ) {
$cp[] = 'BEGIN:VALARM';
$cp[] = 'TRIGGER:-PT' . $val;
$cp[] = 'ACTION:DISPLAY';
$cp[] = 'END:VALARM';
} elseif ( $key === 'dtstart' || $key === 'dtend' ) {
$cp[]= strtoupper($key).';TZID=Asia/Kolkata:'.$val;
} else {
$cp[]= strtoupper($key).':'.$val;
}
}
$cp[]= 'END:VEVENT';
}
$cp[]='END:VCALENDAR';
}
return implode("\r\n", $cp);
}
}
You want to use the DATE format defined in https://www.rfc-editor.org/rfc/rfc5545#section-3.3.4
You can either choose to provide only a DTSTART:
DTSTART;VALUE=DATE:20190703
or, if the allay event last for a longe period of time, provide both DTSTART and DTEND using that same format:
DTSTART;VALUE=DATE:20190703
DTEND;VALUE=DATE:20190712
See also https://devguide.calconnect.org/Handling-Dates-and-Times/
Hello I am writing an php application and currently I'm stuck at a method that retrives flights from the database and applies diffrent filters to it. There are no problems when I initially load the page without any filters applied, all records from DB are loaded as expected. Then again everything as expected when I use "Departure Airport" or "Arrival Airport" filters along with "Bookable Only" filter.
It is whole of another story when you try to use "Bookable Only" filter on its own, it doesn't load any records from database. That's the same with "Aircraft" filter, doesn't work on its own and with "Bookable Only" filter but works when combined with both or either one of Airport filters + "Bookable Only" filter
Schedules_model.php
public function getFilteredSchedule($available, $departureICAO, $arrivalICAO, $specificAircraftId)
{
$this->db->select('*');
if($departureICAO != FALSE) {
$this->db->where('departureICAO', $departureICAO);
}
if($arrivalICAO != FALSE) {
$this->db->where('arrivalICAO', $arrivalICAO);
}
if($specificAircraftId != FALSE) {
$this->db->where('aircraftId', $specificAircraftId);
}
$schedules = $this->db->where('active', 1)
->order_by('id', 'asc')
->get('schedules')
->result_array();
$schedulesAvailable = array();
if($available === TRUE) {
echo 'work';
foreach($schedules as $key => $schedule) {
if($this->RebuildVA->mustBeAtDepartureAirport()) {
if($this->Aircrafts->isAtAirport($schedule['aircraftId'], $schedule['departureICAO'])) {
$schedulesAvailable[$key] = $schedule;
} else {
break;
}
} else {
$schedulesAvailable[$key] = $schedule;
}
if(!$this->RebuildVA->allowMultipleAircraftBookings()) {
if(!$this->Aircrafts->isBooked($schedule['aircraftId'])) {
$schedulesAvailable[$key] = $schedule;
} else {
break;
}
} else {
$schedulesAvailable[$key] = $schedule;
}
if(!$this->RebuildVA->allowMultiplePilotBookings()) {
if(!$this->Pilots->hasBookedFlight($this->session->userdata('pilotId'))) {
$schedulesAvailable[$key] = $schedule;
} else {
break;
}
} else {
$schedulesAvailable[$key] = $schedule;
}
}
} else {
$schedulesAvailable = $schedules;
}
return $schedulesAvailable;
}
schedules.php
public function search()
{
$this->data['pageTitle'] = 'Schedule Search';
$this->data['pageDisplayedTitle'] = 'Schedule Search';
$available = (bool) $this->input->post('available');
$this->data['schedules'] = $this->Schedules->getFilteredSchedule($available, $this->input->post('departureICAO'), $this->input->post('arrivalICAO'), $this->input->post('aircraftId'));
$airportsList = $this->Airports->getAllAirports(TRUE, TRUE); // Get set of all active airports
$aircraftsList = $this->Aircrafts->getAllAircrafts(TRUE, TRUE); // Get set of all active airports
// Prepare form inputs
$this->data['departureICAO'] = array(
'name' => 'departureICAO',
'id' => 'departureICAO',
'selected' => $this->input->post('departureICAO'),
'options' => $airportsList,
);
$this->data['arrivalICAO'] = array(
'name' => 'arrivalICAO',
'id' => 'arrivalICAO',
'selected' => $this->input->post('arrivalICAO'),
'options' => $airportsList,
);
$this->data['aircraftId'] = array(
'name' => 'aircraftId',
'id' => 'aircraftId',
'selected' => $this->input->post('aircraftId'),
'options' => $aircraftsList,
);
$this->data['available'] = array(
'name' => 'available',
'id' => 'available',
'checked' => set_checkbox('available', $this->input->post('available'), FALSE),
'value' => TRUE,
);
$this->load->view('schedules/scheduleSearch', $this->data);
}
I tried debugging everything and following the process step by step as well as trial and error method but none give expected effects. Any ideas?
By trial and error method I have found some kind of a work around that some how does the job. If anyone has any suggestions regarding it or how I could improve it, please feel free, as I am looking for performance in the app.
The required changes were in the Model:
public function getFilteredSchedule($available, $departureICAO, $arrivalICAO, $specificAircraftId)
{
$this->db->select('*');
if($departureICAO != FALSE) {
$this->db->where('departureICAO', $departureICAO);
}
if($arrivalICAO != FALSE) {
$this->db->where('arrivalICAO', $arrivalICAO);
}
if($specificAircraftId != FALSE) {
$this->db->where('aircraftId', $specificAircraftId);
}
$schedules = $this->db->where('active', 1)
->order_by('id', 'asc')
->get('schedules')
->result_array();
$schedulesAvailable = array();
// Check if any of the filters is required
if(!$this->RebuildVA->mustBeAtDepartureAirport() && $this->RebuildVA->allowMultipleAircraftBookings() && $this->RebuildVA->allowMultiplePilotBookings()) {
$schedulesAvailable = $schedules;
// Check if only bookable flights has been checked
} elseif($available === TRUE) {
foreach($schedules as $key => $schedule) {
// Allow multiple schedule bookings
// Check if the aircraft must be at departure airport
if($this->RebuildVA->mustBeAtDepartureAirport()) {
if($this->Aircrafts->isAtAirport($schedule['aircraftId'], $schedule['departureICAO'])) {
$schedulesAvailable[$key] = $schedule;
} else {
// Check if use of other aircraft of same type is allowed
if($this->RebuildVA->allowOtherAircraftUse()) {
if($this->Aircrafts->aircraftTypeAtAirport($schedule['aircraftId'], $schedule['departureICAO'])) {
$schedulesAvailable[$key] = $schedule;
} else {
unset($schedulesAvailable[$key]);
continue;
}
} else {
unset($schedulesAvailable[$key]);
continue;
}
}
} else {
if(isset($schedulesAvailable[$key])) {
$schedulesAvailable[$key] = $schedule;
}
}
// Check if there is a limit of only one booking at time per aircraft
if(!$this->RebuildVA->allowMultipleAircraftBookings()) {
if(!$this->Aircrafts->isBooked($schedule['aircraftId'])) {
$schedulesAvailable[$key] = $schedule;
} else {
unset($schedulesAvailable[$key]);
continue;
}
} else {
if(isset($schedulesAvailable[$key])) {
$schedulesAvailable[$key] = $schedule;
}
}
// Check if there is a limit of only one booking at time per pilot
if(!$this->RebuildVA->allowMultiplePilotBookings()) {
if(!$this->Pilots->hasBookedFlight($this->session->userdata('pilotId'))) {
$schedulesAvailable[$key] = $schedule;
} else {
unset($schedulesAvailable[$key]);
continue;
}
} else {
if(isset($schedulesAvailable[$key])) {
$schedulesAvailable[$key] = $schedule;
}
}
}
} else {
$schedulesAvailable = $schedules;
}
return $schedulesAvailable;
}
I'd like to make a hit counter that will add the count when user enter the website through their ip address. This is my code:
for views:
<?php echo number_format(Visitor::model()->GetAll('portal')); ?>
this is my model:
public function attributeLabels() {
return array(
'id' => 'ID',
'web' => 'Web',
'dtvisit' => 'Dtvisit',
'total' => 'Total',
);
}
public function AddVisitor($web) {
date_default_timezone_set('Asia/Kuala_Lumpur');
$today = date('Y-m-d');
$model = $this->findByAttributes(array('dtvisit' => $today, 'web' => $web));
if (sizeof($model) > 0) {
//update
$model2 = $this->findByPk($model->id);
$model2->total = (1 + $model->total);
$model2->save();
} else {
//add new
$model2 = new Visitor;
$model2->web = $web;
$model2->dtvisit = $today;
$model2->total = 1;
$model2->save();
}
}
public function GetAll($web) {
date_default_timezone_set('Asia/Kuala_Lumpur');
$model = $this->findAll(array("condition" => "web='$web'"));
$total = 0;
if (sizeof($model) > 0) {
foreach ($model as $row) {
$total+= (int) $row->total;
}
}
return $total;
}
CUrrently, the total will add everytime I refresh or click any links on my website. How to make it add the total only when new user enter the website. Thank you
I think you should use Params for passing value
public function GetAll($web) {
date_default_timezone_set('Asia/Kuala_Lumpur');
$model = $this->findAll(array("condition" => "web=':web'",
'params' => array(:web=$web)));
$total = 0;
if (sizeof($model) > 0) {
foreach ($model as $row) {
$total+= (int) $row->total;
}
}
return $total;
}
In the below codeigniter code i have placed controller and model.In my membership table i have 4 columns exam name,month,year and college name.
Exam name month year college name
anna univ feb 2013 kings
anna sep 2014 srm
Now my aim when i login with kings college it display that particular college information .but when i update kings information it displays srm information also.Pls help me to solve the issue.
Controller:
class Exam_site extends ci_controller
{
function index()
{
$data = array();
$college_name = $this->session->userdata('college_name');
if($query = $this->exam_model->get_records($college_name))
{
$data['records'] = $query;
}
$this->load->view('exam_view', $data);
}
function index1()
{
$data = array();
$keyword = $this->input->post('keyword');
if($keyword!=""){
$data['results'] = $this->exam_model->search($keyword);
}
$this->load->view('exam_view', $data);
}
function input()
{
$data = array();
$this->load->view('exam_view', $data);
}
function manage_customers()
{
$data['title']="Manage Customers";
//query model to get data results for form
$data=array();
if($query=$this->exam_model->get_customer_records())
{
$data['records']=$query;
}//end of if bracket
$editcustomer = $this->input->post('editcustomer');
if( $this->input->post('editcustomer') != false )
{
foreach($editcustomer as $row_id)
{
$this->form_validation->set_rules("exam_name_" .$row_id,"'exam name'","required");//to show validation in udata screen
$this->form_validation->set_rules("month_".$row_id,"`month`","required");//to show validation in udata screen
$this->form_validation->set_rules("year_".$row_id,"`year`","required");//to show validation in udata screen
}//end of foreach bracket
}//end of if bracket
if ($this->form_validation->run() == FALSE)
{
$data["message"]="";
$this->load->view("exam_view",$data);
} //end of if bracket
else
{
// single update - working
if( $this->input->post('editcustomer') != false )
{
foreach ($editcustomer as $row_id)
{
$data = array(
'college_name' => $this->session->userdata('college_name'),
'exam_name' => $this->input->post('exam_name_'.$row_id),
'month' => $this->input->post('month_'.$row_id),
'year' => $this->input->post('year_'.$row_id),
);//end of the array
//this is update the data when it click
$this->exam_model->update_customer_records( $row_id, $data );
}//end of foreach bracket
//Not Working
$this->session->set_flashdata('dbaction', 'Selected Records have been updated successfully');
redirect('exam_site/manage_customers', 'refresh');
}//end of if bracket
}//end of function
}
}//end of class
model:
class Exam_model extends ci_model {
function get_records($college_name)
{
$this->db->where('college_name',$college_name);
$query = $this->db->get('exam_table');
return $query->result();
}
/* function add_record($data)
{
$this->db->insert('exam_table', $data);
return;
}*/
function update_record($data)
{
$temp = 'exam_name'.$this->uri->segment(3);
echo "temp:".$temp;
echo "data:".$this->input->post($temp);
$data1 = array(
'exam_name' => $this->input->post('exam_name.$this->uri->segment(3)'),
'month'=>$this->input->post('month.$this->uri->segment(3)'),
'year'=>$this->input->post('year.$this->uri->segment(3)')
);
echo "exam_name:".$data1['exam_name'];
echo " month:".$data1['month'];
echo "year:".$datal['year'];
}
function send($data) {
$this->db->insert('msg', $data);
return;
}
function get_customer_records()
{
$query = $this->db->get('exam_table');
return $query->result();
}
function update_customer_records($row_id, $data)
{
$this->db->where('id',$row_id);
$this->db->update('exam_table',$data);
if ($this->db->_error_number() == 1451)
{
$this->session->set_flashdata('updatecascade', 'updatecascade');
}
if ($this->db->_error_number() == "")
{
$this->session->set_flashdata('update', 'update');
}
}
}
Can you provide the value of $this->input->post('editcustomer')?
Also in your controller you are missing one closing bracket } at the end. The line of comment which says //end of function is actually end of else bracket.
In the below codeigniter code I have placed the controller and model. My aim is to store the session college name in the db. I tried but it is not entering the session college name into db.college_name is in blank.
Controller
function create() {
$j=1;
$createcustomer = $this->input->post('createcustomer');
if( $this->input->post('createcustomer') != false ) {
foreach($createcustomer as $row_id) {
//this is validation command to update on the screen
$this->form_validation->set_rules("exam_name_" . $row_id, "'Exam name'","required");
$this->form_validation->set_rules("month_". $row_id,"`Month`","required");
$this->form_validation->set_rules("year_". $row_id,"`Year`","required","required|");
}
}
if ($this->form_validation->run() == FALSE) {
$data["message"]="";
$this->load->view("exam_view",$data);
} else {
while($j<=$this->uri->segment(3)) {
$data = array(
'exam_name' => $this->input->post('exam_name_'.$j),
'month' => $this->input->post('month_'.$j),
'year' => $this->input->post('year_'.$j)
);
$exam_name=$this->input->post('exam_name_'.$j);
$data1 = $this->session->userdata("college_name");
if ($exam_name != "") {
$this->exam_model->add_record($data,$data1);
// $this->load->view("success_msg",$data);
}
$j++;
} //end of while condition
} //end of if condition
redirect('exam_site', 'refresh');
//$this->index();
}
Model:
function add_record($data,$data1) {
$this->db->insert('exam_table', $data,$data1);
//$this->db->insert('exam_table', $data1);
if ($this->db->_error_number() == 1062) {
$this->session->set_flashdata('duplicate', 'duplicate');
}
if ($this->db->_error_number() == "") {
$this->session->set_flashdata('create', 'create');
}
return;
}
change this:
$this->db->insert('exam_table', $data,$data1);
to this:
$this->db->insert('exam_table', $data);
$this->db->insert('exam_table', $data1);