With respect to Code Igniter And MySql:
How to hide index.php from Url by htaccess?
views:
80answers:
2
+4
A:
See the CodeIgniter Manual.
In your document root, a .htaccess file containing the following:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt) # these are examples,
# add everything here that
# you **don't** want to be
# routed to CI
RewriteRule ^(.*)$ /index.php/$1 [L]
Then in application/config/config.php change:
$config['index_page'] = '';
chigley
2010-10-13 06:48:08
A:
=======Controller===========================================================
function employee()
{
parent::Controller();
$this->load->model('empmodel');
$this->load->helper('url');
$this->load->helper('file');
}
function index()
{
$this->load->view('welcome_message');
}
function newemp()
{
$this->load->view('newemp');
}
function getemp()
{
if ( $_POST['ename'] != '' || $_POST['eadd'] != '')
{
$data['e_name'] = $_POST['ename'];
$data['e_desig'] = $_POST['edesi'];
$data['e_add'] = $_POST['eadd'];
$flag;
$this->empmodel->insert_entry($data);
$this->viewemp();
}//print_r($data);
else {
$this->viewemp();
}
}
function viewemp()
{
$data = $this->empmodel->getrecords();
// print_r($data);
//-----------------
$query = "select count(e_desig) as Total,e_desig as Designation from emp GROUP BY e_desig";
$query = $this->db->query($query);
$data4 = $query->result_array();
$parsedata = array('data'=>$data,'data4'=>$data4);
$this->load->view('empview',$parsedata);
}
function example()
{
$this->load->view('example');
}
function deleteemp()
{
//print_r($_POST);
$data1 = $_POST;
$this->empmodel->deleterecords($data1);
$this->viewemp();
}
function editemp($id)
{
$query = "select * from emp where e_no = " . $id ;
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
$data2['e_name'] = $row['e_name'];
$data2['e_desig'] = $row['e_desig'];
$data2['e_add'] = $row['e_add'];
$data2['e_no'] = $row['e_no'];
}
//echo $data2['e_no'] . " " . $data2['e_name'];
//exit;
$this->load->view('editemp',$data2);
}
function updateemp()
{
$data['e_name'] = $_POST['ename'];
$data['e_desig'] = $_POST['edesi'];
$data['e_add'] = $_POST['eadd'];
$data['e_no'] = $_POST['eno'];
$this->db->where('e_no', $data['e_no']);
$this->db->update('emp', $data);
$this->viewemp();
}
function searchemp()
{
$this->load->view('searchemp');
}
}
?>
==========================================================
===========Model==========================================
db->insert('emp', $data);
}
/* function update_entry()
{
$this->title = $_POST['title'];
$this->content = $_POST['content'];
$this->date = time();
$this->db->update('emp', $this, array('id' => $_POST['id']));
}
*/
function getrecords()
{
$query = $this->db->get('emp');
return $query->result();
}
function getrecordsForChartEmpDesig($designation)
{ $this->db->where('e_desig',$designation);
$this->db->select('Count(e_desig) AS total');
$query = $this->db->get('emp');
return $query->result();
// $this->db->where('e_no', $data['e_no']);
// $this->db->update('emp', $data);
}
function deleterecords($data)
{
// print_r($data);
//Array ( [checkbox] => Array ( [0] => 0 [1] => 2 [2] => 3 ) )
$temp = $data['checkbox'];
$start= 0;
$total = count($temp);
$ids = implode(',',$temp);
// $this->db->delete('emp', array('e_no' => 0));
$query = "delete from emp where e_no in(" . $ids . ")";
$this->db->query($query);
}
}
?>
=====================================================
==============view======================
foreach($data4 as $row)
{
$row['Designation']
$row['Total']
}
foreach($data as $row)
{
echo $row->e_no;
echo $row->e_add;
}
Bhavin Rana
2010-10-13 07:25:43
You can edit your question... this is not an answer.
captaintokyo
2010-10-13 07:58:19