我使用Codeigniter開發了自己的基於Web的圖書館系統。我對活躍的記錄感到困惑。爲了明確的目的,請參閱下面我的代碼:我的數據庫列互相交換
//Add Publisher Form
<form action="<?php echo base_url(); ?>admin/addPublisher" method="post" class="form-horizontal" role="form">
<div class="col-lg-12">
<div class="row">
<div class="form-group">
<label for="penerbit" class="col-lg-2 control-label">Publisher</label>
<div class="col-lg-9">
<input type="text" name="publisher" class="form-control">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label for="website" class="col-lg-2 control-label">Website</label>
<div class="col-lg-9">
<input type="text" name="website" class="form-control">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label for="email" class="col-lg-2 control-label">Contact</label>
<div class="col-lg-9">
<input type="text" name="phone" class="form-control">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label for="telepon" class="col-lg-2 control-label">E-mail</label>
<div class="col-lg-9">
<input type="text" name="email" class="form-control">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label for="alamat" class="col-lg-2 control-label">Address</label>
<div class="col-lg-9">
<textarea name="address" class="form-control" rows="5"></textarea>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label for="" class="col-lg-2"></label>
<div class="col-lg-9">
<button type="submit" class="btn btn-success">Add Publisher</button>
</div>
</div>
</div>
</div>
</form>
// Add Publisher @ Admin Controller
public function addPublisher()
{
if($this->session->userdata('logged_in'))
{
$publisher = $this->input->post('publisher');
$web = $this->input->post('website');
$email = $this->input->post('email');
$phone = $this->input->post('phone');
$addr = $this->input->post('address');
if(!empty($publisher) && !empty($web) && !empty($email) && !empty($phone) && !empty($addr)){
$this->adminModel->insertPublisher($publisher, $web, $email, $phone, $addr);
redirect ('admin/publisher');
} else {
redirect ('admin/publisher');
}
$session_data = $this->session->userdata('logged_in');
$data['user'] = $session_data['user'];
$data['pubs'] = $this->adminModel->getAllPublisher();
$data['tittle'] = "Add Publisher Page";
$this->load->view('admin/static/header', $data);
$this->load->view('admin/static/header-nav');
$this->load->view('admin/static/left-nav');
$this->load->view('admin/publisher/publisher', $data);
} else {
$this->index();
}
}
// Here my adminModel for inserting records
public function insertPublisher($publisher, $web, $phone, $email, $address)
{
$query = $this->db->query("INSERT INTO publisher (`id_publisher`, `publiser`, `website`, `phone`, `email`, `address`, `created_at`) VALUES ('', '$publisher', '$web', '$phone', '$email', '$address', NOW())");
return $query;
}
// The output in print_r()
stdClass Object
(
[id_publisher] => 1
[publisher] => Example Publishing
[website] => example.com
[phone] => [email protected] <--- this is my point
[email] => 1234567 <--- and this is
[address] => asdfgj
[create_at] => 2014-04-30 10:48:08
)
我的問題是:
- 是什麼原因導致「手機」和「電子郵件」列之間的交流?
- 如何按字母順序排序發佈者的視圖?
非常感謝您的建議。
我的天啊。感謝您的建議@Mohit Jain。你真棒 – life4learn