I'm making a fuction on the CodeIgniter framework so users are able to edit/update product detail information. But when I submit the form I get a blank page and the product isn't updated in my database. I couldn't find a mistake myself.
Here is my view file form (cadeaubewerken.php):
<table class="aanbieding-cadeau">
<form action="<?php echo base_url() . "KdGwController/update_product"; ?>" method="post">
<tr>
<h4>Cadeau naam</h4>
<td><?php echo form_input(array('id'=>'product_naam', 'name'=>'product_naam', 'value' => $product["product_naam"] , 'size'=>25));?></td>
<td><?php echo form_input(array('type'=>'hidden','id'=>'product_id', 'name'=>'product_id', 'value' => $product['product_id']));?>
</tr>
<tr>
<td><?php echo form_open_multipart('Product/upload'); ?> </td>
</tr>
<tr>
<td>
<h4>Kies een categorie</h4>
<select name="category_id">
<?php foreach (get_categories_h() as $category) :
if ($category->id == $product["category_id"]){
echo '<option value="'.$category->id .'" selected>' . $category->name . '</option>';
}else{
echo '<option value="'.$category->id .'">'.$category->name . '</option>';
}
endforeach; ?>
</select>
</td>
</tr>
<tr>
<td><h4>Ophaal plaats</h4><?php echo form_input(array('id'=>'ophaal_plaats', 'name'=>'ophaal_plaats', 'value' => $product["ophaal_plaats"], 'size'=>25));?></td>
<td><?php echo form_input(array('type'=>'hidden','id'=>'ophaal_plaats', 'name'=>'ophaal_plaats', 'value' => $product['ophaal_plaats']));?>
</tr>
<tr>
<td>
<div class="checkbox">
<label><input type="checkbox" value="">Gebruik adres van mijn account</label>
</div>
</td>
</tr>
<tr>
<td>
<h4>Huidig cadeau profiel foto</h4>
<img src="<?php echo base_url(); ?>upload/<?php echo $product['product_foto_thumb']; ?>" class="img-responsive">
</td>
</tr>
<tr>
<td>
<h4>Cadeau profiel foto veranderen</h4>
<input type="file" name="userfile"/>
</td>
</tr>
<tr>
<td><?php echo form_textarea(array('type'=>'textarea','id'=>'product_beschrijving', 'name'=>'product_beschrijving', 'value' =>$product['product_beschrijving'], 'size'=>25));?></td>
<td><?php echo form_input(array('type'=>'hidden','id'=>'product_beschrijving', 'name'=>'product_beschrijving', 'value' => $product['product_beschrijving']));?>
</tr>
<tr>
<td><input type="submit" class="btn btn-primary" name="submit" value="Cadeau bewerken!" /></td>
</tr>
</table>
</form>
This is my controller file (KdGwController.php):
<?php
class KdGwcontroller extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('Product_model');
$this->load->model('Update_product_model');
$this->load->helper(array('form', 'url'));
}
public function details_bewerken($product_id) {
//load the Product_model
$this->load->model('Product_model');
//call function getdata in de Product_model
$data['userdetail_list'] = $this->Product_model->getdata();
//get product details
$data['product'] = $this->Product_model->get_product_details($product_id);
//laad view
$data['main_content'] = 'cadeaubewerken';
$this->load->view('cadeaubewerken',$data);
}
public function update_product() {
$id= $this->input->post('product_id');
$data = array(
'product_naam' => $this->input->post('product_naam'),
'category_id' => $this->input->post('category_id'),
'ophaal_plaats' => $this->input->post('ophaal_plaats'),
);
}
}
And this is my model file : (Update_product_model.php):
<?php
class Update_product_model extends CI_Model {
function update_product($id,$data){
$this->db->where('product_id', $id);
$this->db->update('products', $data);
header ('location:https://kadokado-ferran10.c9users.io//AlleCadeausController');
}
}
?>
No need to add update in model.
Also, your controller update function should be like
public function update_product() {
$id= $this->input->post('product_id');
$data = array(
'product_naam' => $this->input->post('product_naam'),
'category_id' => $this->input->post('category_id'),
'ophaal_plaats' => $this->input->post('ophaal_plaats'),
);
// here I am assuming that `Product` is model
$this->Product->where($id);
$this->Product->update($data);
}
You have not call model function in your controller.
Change your controller update_product() function like this
public function update_product() {
$id= $this->input->post('product_id');
$data = array(
'product_naam' => $this->input->post('product_naam'),
'category_id' => $this->input->post('category_id'),
'ophaal_plaats' => $this->input->post('ophaal_plaats'),
);
$this->Update_product_model->update_product($id,$data);
}
You are not calling function update_product() of Update_product_model.php from KdGwController.php
Change this in your controller...
public function update_product() {
$id= $this->input->post('product_id');
$data = array(
'product_naam' => $this->input->post('product_naam'),
'category_id' => $this->input->post('category_id'),
'ophaal_plaats' => $this->input->post('ophaal_plaats'),
);
$this->Update_product_model->update_product($id,$data); // this line you missed
}
Related
I want my admin table view to reload after uses selects Edit, changes entry and selects Update Entry with the edits reflected in the revised table row.
The admin edit page is working fine, and I know the solve for redirecging the update to the table page is basic. Some light guidance would be much appreciated!
Admin View:
<html>
<head>
<title>Admin Page</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body background=http://wallpapercave.com/wp/ItmVuT6.jpg>
<div class="container">
<table class="table table-bordered">
<center>
<thead>
<tr style="font-size: 24; color: white;">
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th colspan="2">Actions</th>
</tr>
</thead>
</center>
<tbody style="background-color: #F0F8FF;">
<?php
foreach($users as $u)
{
$class = "btn btn-primary";
$button = "Approve";
?>
<tr style="font-size: 20;">
<td><?php echo $u->first_name; ?></td>
<td><?php echo $u->last_name; ?></td>
<td><?php echo $u->email; ?></td>
<td><a class="btn btn-success" href="<?php echo site_url('myform/edituser/' . $u->id); ?>">Edit</a></td>
<td><a class="<?php echo $class;?>" href="/ci/index.php/myform/approve/?user_id=<?php echo $u->id;?>"><?php echo $button;?></a></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</body>
</html>
Admin Edit View:
<html>
<head>
<title>Edit User Info</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body background=http://wallpapercave.com/wp/ItmVuT6.jpg>
<div class="container">
<div class="jumbotron">
<form action="" method="post">
<p><font color="black" font size='5'/><strong>Entry for ID </strong><strong>"<?php echo $id; ?>"</strong></font></p>
<font color="black" font size='5'/><strong>First Name </strong></font><input type="text" name='first_name' value="<?php echo $first_name; ?>"?><br/>
<font color="black" font size='5'/><strong>Last Name </strong></font><input type="text" name='last_name' value="<?php echo $last_name; ?>"/><br/>
<font color="black" font size='5'/><strong>Email </strong></font><input type="text" name='email' value="<?php echo $email; ?>"/><br/>
<br/>
<input type="button" class="btn btn-info" value="Update Entry">
</div>
</div>
</form>
</body>
</html>
Controller:
<?php
class Myform extends CI_Controller{
public function __construct(){
parent::__construct();
}
public function index(){
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('user[first_name]', 'First Name', 'required');
$this->form_validation->set_rules('user[last_name]', 'Last Name', 'required');
$this->form_validation->set_rules('user[email]', 'Email Address', 'required|trim');
$form['userValues'] = [
'first_name' => $this->input->post('user[first_name]'),
'last_name' => $this->input->post('user[last_name]'),
'email' => $this->input->post('user[email]'),
'id' => $this->input->post('id'),
];
if ($this->form_validation->run() == FALSE)
{
$this->load->view('myform');
}
else
{
$user = $this->input->post('user');
//$company = $this->input->post('company');
echo '<pre>';
print_r($user);
//print_r($company);
if ($this->input->post('id') !== '' && $this->input->post('id') !== NULL)
{
$this->db->where('id', (int) $this->input->post('id'));
$this->db->update("User_Inputs", $user);
}
else
{
$this->db->insert("User_Inputs", $user);
}
//$this->db->insert("companies", $company);
redirect("/myform/successmessage");
}
}
public function successmessage(){
$this->load->view('formsuccess');
}
public function getDatabase(){
$data['users'] = $this->db->get("User_Inputs")->result();
$this->load->view('adminlogin', $data);
}
public function approve(){
$id = $this->input->get("user_id");
$this->db->where("id", $id);
$data['user'] = $this->db->get("User_Inputs")->row();
echo "<pre>";
print_r($this->db->last_query());
print_r($data);
echo "<h1>". $data['user']->email."</h1>";
die();
}
public function edituser($user_id = NULL)
{
$user_id = (int) $user_id;
$data['user'] = $this->db
->where('id', $user_id)
->get("User_Inputs")
->row();
$form['dbValue'] = [
'first_name' => $data['user']->first_name,
'last_name' => $data['user']->last_name,
'email' => $data['user']->email,
'id' => $user_id
];
$this->load->view('editfields', $data['user']);
}
}
i have a problem : I have a view that needs to call a method in my controller EmployeeController to go to the page to add an employee. But it don't work.. also with other views it doe
This is the view:
<body>
<form class="form-horizontal" id='employeeform' id='employeeform' action="<?php echo base_url();?>EmployeeController/addEmployee" method="post">
<div class="container">
<div class="row">
<div class="col-lg-12 col-sm-12">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>#</th>
<th>ID</th>
<th>Naam werknemer</th>
<th>Datum aanwerving</th>
<th>Salaris</th>
</tr>
</thead>
<tbody>
<?php for ($i = 0; $i < count($employeelist); ++$i) { ?>
<tr>
<td><?php echo ($i+1); ?></td>
<td><?php echo $employeelist[$i]->employee_no; ?></td>
<td><?php echo $employeelist[$i]->employee_name; ?></td>
<td><?php echo $employeelist[$i]->hired_date; ?></td>
<td><?php echo $employeelist[$i]->salary; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<input id="btn_add" name="btn_add" type="submit" class="btn btn-primary" value="Add employee" />
</div>
</div>
</div>
</form>
</body>
THIS IS THE CONTROLLER:
class EmployeeController extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->library('session');
$this->load->helper('form');
$this->load->helper('url');
$this->load->database();
$this->load->library('form_validation');
//load the employee model
$this->load->model('employee_model');
}
//index function
function index() {
$employeelist = $this->employee_model->get_employee_list();
$data['employeelist'] = $employeelist;
$this->load->view('employee/employee_add', $data);
}
function createEmployee() {
$this->form_validation->set_rules('employee_no', 'Employee No', 'trim|required|numeric');
$this->form_validation->set_rules('employee_name', 'Employee Name', 'trim|required|xss_clean|callback_alpha_only_space');
$this->form_validation->set_rules('hired_date', 'Hired Date', 'required');
$this->form_validation->set_rules('salary', 'Salary', 'required|numeric');
if ($this->form_validation->run() == FALSE) {
//fail validation
$this->load->view('employee/employee_add');
} else {
//pass validation
$data = array(
'employee_no' => $this->input->post('employeeno'),
'employee_name' => $this->input->post('employeename'),
'hired_date' => #date('Y-m-d', #strtotime($this->input->post('hireddate'))),
'salary' => $this->input->post('salary'),
);
//insert the form data into database
$this->db->insert('tbl_employee', $data);
//display success message
$employeeresult = $this->employee_model->get_employee_list();
$data['employeelist'] = $employeeresult;
//load the department_view
$this->load->view('employee/employee_view', $data);
redirect('employee/employee_view');
}
}
function addEmployee() {
$this->load->view('employee/employee_add');
//set validation rules
}
}
?>
THE ERROR I GET IS :
The requested URL /BoMaTec_afstudeerproject/CodeIgniter-3.0.1/EmployeeController/createEmployee was not found on this server.
Seems like you don't have any router for that url, or the router is wrong. As per the error, it's trying to load a folder named EmployeeController and within that folder, another folder named createEmployee. Check your .htaccess file and your routers in the framework you are using.
I am beginner in CodeIgniter. I want to insert records in database. Here is my view file. I save view file as a register.php and my model file as register_insert.php and controller file as register.php and my table name in mysql is "register".
View
<?php $this->load->view('layot/header'); ?>
<html>
<head>
<title>Register</title>
<style>
td {
border:none;
}
</style>
</head>
<form method="POST" action="register">
<table border="1" align="center">
<tr>
<td>User Name : <input type="text" name="u_nm"></td>
</tr>
<tr>
<td>Password : <input type="text" name="pwd"></td>
</tr>
<tr>
<td>E-Mail: <input type="text" name="eid"></td>
</tr>
<tr>
<td>Contact No : <input type="text" name="cno"></td>
</tr>
<tr>
<td>Mobile No : <input type="text" name="mbo"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" value="Register"></td>
</tr>
</table>
</form>
</html>
</table>
This is my controller file..
public function index()
{
if(isset($_POST['submit']))
{
$data = array(
'u_nm' => $this->input->post('u_nm'),
'pwd' => $this->input->post('pwd'),
'eid' => $this->input->post('eid'),
'cno' => $this->input->post('cno'),
'mbo' => $this->input->post('mbo'),
);
$this->register_insert->form_insert($data);
}
$this->load->view('register');
}
}
?>
This is my model file..
<?php
class Register extends CI_Model
{
function __construct() {
parent::__construct();
}
function form_insert($data){
$this->db->insert('register', $data);
}
}
?>
}
?>
I think you need to load model register in controller
public function __construct(){
parent::__construct();
$this->load->model('register');
}
In function index, you need to call class name register
public function index()
{
if(isset($_POST['submit']))
{
$data = array(
'u_nm' => $this->input->post('u_nm'),
'pwd' => $this->input->post('pwd'),
'eid' => $this->input->post('eid'),
'cno' => $this->input->post('cno'),
'mbo' => $this->input->post('mbo'),
);
$this->register->form_insert($data);
}
$this->load->view('register');
}
}
And in model you can return the last insert id after inserted
public function form_inssert($data){
$this->db->insert('register',$data);
return $this->db->insert_id();
}
This is my controller file
<?php
class Register extends CI_Controller{
public function index()
{
$this->load->model('register_insert');
if(isset($_POST['submit']))
{
$data = array(
'u_nm' => $this->input->post('u_nm'),
'pwd' => $this->input->post('pwd'),
'eid' => $this->input->post('eid'),
'cno' => $this->input->post('cno'),
'mbo' => $this->input->post('mbo'),
);
$this->register_insert->form_insert($data);
}
$this->load->view('register');
}
}
?>
And This is my model file
<?php
class Register_insert extends CI_Model
{
function __construct()
{
parent::__construct();
}
function form_insert($data)
{
$this->db->insert('register', $data);
}
}
?>
My mistake is naming of my model class name is "Register_insert" and my old class name is Register that is why my model is not load properly..
in your controller function as given below:
public function index()
{
if(isset($_POST['submit']))
{
$data = array(
'u_nm' => $this->input->post('u_nm'),
'pwd' => $this->input->post('pwd'),
'eid' => $this->input->post('eid'),
'cno' => $this->input->post('cno'),
'mbo' => $this->input->post('mbo'),
);
$this->register_insert->form_insert($data);
redirect('register');
}
$this->load->view('register');
}
}
in your model file as given below :
function form_insert($data){
$this->db->insert('register', $data);
return true;
}
try this now u get result
You may try this for your view code:
<html>
<head>
<title>Register</title>
<style>
td {
border:none;
}
</style>
</head>
<table border="1" align="center">
<?php echo form_open('register/register_insert'); ?>
<tr>
<td>User name:<?php echo form_input('u_nm'); ?></td>
</tr>
<tr>
<tr>
<td>Password :<?php echo form_input('pwd'); ?></td>
</tr>
<tr>
<td>E-Mail: <?php echo form_input('eid'); ?></td>
</tr>
<tr>
<td>Contact No : <?php echo form_input('cno'); ?></td>
</tr>
<tr>
<td>Mobile No : <?php echo form_input('mbo'); ?></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" value="Register"></td>
</tr>
<?php echo form_close(); ?>
</table>
</form>
</html>
</table>
It is more easier using the form helper. You can autoload this in the autoload.php config file like this:
$autoload['helper'] = array('form');
This will be your controller:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class register extends CI_Controller {
public function index(){
$this->load->view('register');
}
public function register_insert()
{
//Here you can add validations for your form before trying to insert data to your Database
if(isset($_POST['submit']))
{
$this->load->model('register_insert');
$agregar=$this->register_insert->add_user();
}
$this->load->view('register');
}
}
?>
And finally your model code:
<?php if( ! defined('BASEPATH')) exit('No direct script access allowed');
class register_insert extends CI_Model {
public function __construct(){
parent::__construct();
}
public function add_user (){
$data = array(
'u_nm' =>$this->input->post('u_nm'),
'pwd' => $this->input->post('pwd'),
'eid' => $this->input->post('eid'),
'cno' => $this->input->post('cno'),
'mbo' => $this->input->post('mbo'),
);
$this->db->insert('register', $data);
}
}
For this model you will also need to change your autoload.php
you need to autoload the database library:
$autoload['libraries'] = array('database');
i'm having trouble getting my update to work. delete, view and add work fine.
this is my extraoptie_model:
function update($id, $extraOptie) {
$this->db->where('id', $id);
$this->db->update('extraOptie', $extraOptie);
}
my controller:
function update($id) {
// Check admin if not Acces Denied
$gebruiker = $this->session->userdata('gebruiker');
if ($gebruiker->accountLevel != "admin") {
$data['title'] = 'Acces Denied';
$partials = array('header' => 'main_header', 'content' => 'admin_noacces', 'footer' => 'main_footer');
$this->template->load('main_master', $partials, $data);
} else {
// prefill form values
$extraOptie = $this->extraoptie_model->get($id);
$data['id'] = $id;
$data['beschrijving'] = $extraOptie->beschrijving;
$data['actuelePrijs'] = $extraOptie->actuelePrijs;
$data['soort'] = $extraOptie->soort;
$data['aantalGangen'] = $extraOptie->aantalGangen;
$data['tabelNaam'] = $extraOptie->tabelNaam;
// set common properties
$data['title'] = 'Extra optie update';
$data['message'] = '';
$data['action'] = site_url('admin/extraoptie/updateExtraOptie/');
// load view
$partials = array('header' => 'main_header', 'content' => 'admin_extraoptieedit', 'footer' => 'main_footer');
$this->template->load('main_master', $partials, $data);
}
}
function updateExtraOptie() {
// Check admin if not Acces Denied
$gebruiker = $this->session->userdata('gebruiker');
if ($gebruiker->accountLevel != "admin") {
$data['title'] = 'Acces Denied';
$partials = array('header' => 'main_header', 'content' => 'admin_noacces', 'footer' => 'main_footer');
$this->template->load('main_master', $partials, $data);
} else {
// set common properties
$data['title'] = 'Update extra optie';
$data['action'] = site_url('admin/extraoptie/updateExtraOptie');
// save data
$id = $this->input->post('id');
$extraOptie = array('beschrijving' => $this->input->post('beschrijving'),
'actuelePrijs' => $this->input->post('actuelePrijs'),
'soort' => $this->input->post('soort'),
'aantalGangen' => $this->input->post('aantalGangen'),
'tabelNaam' => $this->input->post('tabelNaam'));
if ($extraOptie['aantalGangen'] == '') {
$extraOptie['aantalGangen'] = null;
}
if ($extraOptie['tabelNaam'] == '') {
$extraOptie['tabelNaam'] = null;
}
$this->extraoptie_model->update($id, $extraOptie);
// set user message
$data['message'] = '<div class="success">update success</div>';
// redirect to index
redirect('admin/extraoptie/index', 'refresh');
}
}
my view:
<table class='centered text'>
<form method="post" action="<?php echo $action; ?>">
<?php
$hidden = array('id' => $id);
form_hidden($hidden);
?>
<tr>
<td><?php echo form_label('Beschrijving:', 'beschrijving'); ?></td>
<td><?php echo form_textarea(array('name' => 'beschrijving', 'id' => 'beschrijving', 'value' => $beschrijving, 'cols' => '30', 'rows' => '5')); ?></td>
</tr>
<tr>
<td><?php echo form_label('Prijs:', 'prijs'); ?></td>
<td><?php echo form_input(array('name' => 'actuelePrijs', 'id' => 'actuelePrijs', 'value' => $actuelePrijs, 'size' => '10')); ?></td>
</tr>
<tr>
<td><?php echo form_label('Soort:', 'soort'); ?></td>
<td><?php echo form_input(array('name' => 'soort', 'id' => 'soort', 'value' => $soort, 'size' => '30')); ?></td>
</tr>
<tr>
<td><?php echo form_label('Aantal gangen:', 'aantalGangen'); ?></td>
<td><?php echo form_input(array('name' => 'aantalGangen', 'id' => 'aantalGangen', 'value' => $aantalGangen, 'size' => '10')); ?></td>
</tr>
<tr>
<td><?php echo form_label('Tabel naam:', 'tabelNaam'); ?></td>
<td><?php echo form_input(array('name' => 'tabelNaam', 'id' => 'tabelNaam', 'value' => $tabelNaam, 'size' => '30')); ?></td>
</tr>
<tr>
<td colspan='2' class='center'>
<?php echo form_submit('submit', 'Opslaan', 'id="opslaan"');; ?>
<?php echo form_button('annuleer', 'Annuleren', 'id="annuleer"'); ?>
<?php form_close(); ?>
</td>
</tr>
</table>
All help is welcome have been working on it for couple of hours and can't seem to find the problem.
Grtz Nella
possibly the issue arises from the fact that
you have a php form_close();
but do not have a php form_open();
not sure offhand how CI would react to a close without an open.
Do you have CSRF protection enabled? If so, you will need to either use form_open(), as steve has said, or add a hidden input with your csrf token such as:
<input type="hidden" name="<?php echo $this->security->get_csrf_hash();?>" value="<?php echo $this->security->get_csrf_token_name();?>"/>
Thank you both for your quick response!
I have found the error after staring at the code for another couple of hours together w/ a friend.
the problem was i didn't echo form_hidden($hidden) so no id was passed through to the update model.
<table class='centered text'>
<form method="post" action="<?php echo $action; ?>">
<?php
$hidden = array('id' => $id);
form_hidden($hidden);
?>
<tr>
so it had to be:
<table class='centered text'>
<form method="post" action="<?php echo $action; ?>">
<?php
$hidden = array('id' => $id);
echo form_hidden($hidden);
?>
<tr>
Controller file : function index here
public function index()
{
$this->load->helper('url');
$this->load->helper('form');
$this->load->model('register_model');
$this->load->library("pagination");
$config = array();
$config["base_url"] = base_url()."register";
$config["total_rows"] = $this->register_model->record_count();
$config["per_page"] = 5;
$config["uri_segment"] = 3;
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data["result"] = $this->register_model->fetch_logs($config["per_page"], $page);
$data["links"] = $this->pagination->create_links();
$this->load->view('register',$data);
}
here s my model functions
public function view()
{
$query = $this->db->query("select * from user_login");
return $query->result_array();
}
public function record_count()
{
return $this->db->count_all("user_login");
}
public function fetch_logs($limit, $start)
{
$this->db->limit($limit, $start);
$query = $this->db->get("user_login");
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $data;
}
return false;
}
here s my view codes
<form method="post" accept-charset="utf-8" action="<?php echo base_url(); ?>/register/create" class="myform" id="myform" />
<div style="text-align:left;"><h1>User Registration</h1></div>
<table width="488" border="0">
<tr>
<td colspan="3">User
<input name="user_name" type="text" size="40" /></td>
</tr>
<tr>
<td colspan="3">Pass
<input name="password" type="password" size="40" /></td>
</tr>
<tr>
<td width="278" align="right"><input name="submit" type="submit" value="ADD" class="big_btn"/></td>
<td width="148" align="center"> </td>
<td width="48" align="center"> </td>
</tr>
</table>
<p> </p>
<table width="679" border="1" cellpadding="3" cellspacing="0">
<tr><th width="202" align="center">User</th>
<th width="319" align="center">Password</th>
<th colspan="2" align="center">Action</th>
<?php
foreach ($result as $row)
{
?>
<tr>
<td height="32" align="center"><?php echo $row->user;?> </td>
<td align="center"><?php echo md5($row->pwd);?></td>
<td width="56" align="center"><a href="<?php echo base_url();?>/register/delete/<?php echo $row->id;?>">
<input name="delete" type="button" id="delete" value="x" class="del_btn">
</a></td>
<td width="68" align="center"><?php
$atts = array(
'width' => '700',
'height' => '300',
'scrollbars' => 'no',
'status' => 'no',
'resizable' => 'yes',
'screenx' => '600',
'screeny' => '150'
);
echo anchor_popup(base_url().'/register/viewmore/'.$row->id, '<input name="view" type="button" id="view" value="" class="view_btn">', $atts);
?></td>
</tr>
<?php
}
?>
</table>
</form>
</div> <p><?php echo $links; ?></p>
Here I can see the pagination links but after i clicks on links its giving 404 Page Not Found error
can any one check this and reply??
if your above controller is register controller then you can do
$config["base_url"] = site_url("register"); //this will call the index function of register contoller
Change this
$config["base_url"] = base_url()."register";
to this
$config["base_url"] = base_url('register'); // or you can use site_url('register');
public function index() {
$this->load->helper ( 'url' );
$this->load->helper ( 'form' );
$this->load->model ( 'register_model' );
$this->load->library ( "pagination" );
$config = array ();
$config ["base_url"] = base_url ( 'register/index/' );
$config ["total_rows"] = $this->register_model->record_count ();
$config ["per_page"] = 5;
$config ["uri_segment"] = 3;
$this->pagination->initialize ( $config );
$page = ($this->uri->segment ( 3 )) ? $this->uri->segment ( 3 ) : 0;
$data ["result"] = $this->register_model->fetch_logs ( $config ["per_page"], $page );
$data ["links"] = $this->pagination->create_links ();
$this->load->view ( 'register', $data );
}
I think here is the problem try this
like
$config['base_url'] = site_url('register/index/');