0
我有2個表刪除一行時,它被添加到不同的表
登記的活動和事件,但我想,當按下按鈕它會從事件到註冊事件的事件顯示。 但我無法刪除事件本身 我可以隱藏它,所以它不會出現在網頁上的表?
我使用笨
![在Cassey發佈領域分級劃痕種族事件是兩個表中] [1]
我沒有10美譽所以這裏是一個圖像 鏈接https://www.dropbox.com/s/uzyvblmim0e1s5v/2015-05-19%2013_13_00-Eastern%20Veterans%20Cycling.png?dl=0
型號
function getAll()
{
// get all the records from the schools table
$this->db->select('*');
$this->db->from('tblMeetRace as met');
$this->db->join('tblLocation as loc', 'loc.intLocationID = met.intLocationID');
$this->db->join('tblEvent as eve', 'eve.intEventID = met.intEventID');
//$this->db->Where('intMemberID = 1');
$query = $this->db->get();
// if the number of rows returned is more than 0
if($query->num_rows() > 0) {
// loop through each record (row) and place that
// record into an array called $data
foreach ($query->result() as $row) {
$data[] = $row;
}
}
$query->free_result();
// return the array to the controller
return $data;
function getAll1()
{
// get all the records from the schools table
$this->db->select('*');
$this->db->from('tblMeetRace as met');
$this->db->join('tblLocation as loc', 'loc.intLocationID = met.intLocationID');
$this->db->join('tblRegistration as reg', 'reg.intMeetRaceID = met.intMeetRaceID');
$this->db->join('tblEvent as eve', 'eve.intEventID = met.intEventID');
$this->db->Where('intMemberID = 1');
$query = $this->db->get();
// if the number of rows returned is more than 0
if($query->num_rows() > 0) {
// loop through each record (row) and place that
// record into an array called $data
foreach ($query->result() as $row1) {
$data1[] = $row1;
}
}
$query->free_result();
// return the array to the controller
return $data1;
}
控制器
public function getallevents() {
$this->load->model('events_model');
$data['records'] = $this->events_model->getAll();
$data1['records1'] = $this->events_model->getAll1();
$data3 = $data + $data1;
$this->load->view('view-events', $data3);
}
查看
<!-- code for table of schools -->
<div class="container proper-content">
<div class="bs-example table-responsive">
<h3>Unregistered Events</h3>
<table class="table table-striped table-bordered table-hover">
<thead class="tablebackground">
<tr>
<th> Meet race ID</th>
<th> Event Name</th>
<th> Location</th>
<th> Date</th>
<th> Time</th>
<th> Register</th>
</tr>
</thead>
<tbody>
<?php
foreach ($records as $row):
echo "<tr>";
echo "<td> $row->intMeetRaceID</td>";
//echo "<td> $row->intEventID</td>";
echo "<td> $row->strEventDescription</td>";
echo "<td> $row->strLocationName</td>";
echo "<td> $row->datDate</td>";
echo "<td> $row->timTime</td>";
echo "<td><a class='btn btn-success btn-sm'>Register</a></td>";
echo "</tr>";
endforeach;
?>
</tbody>
</table>
<h3>Registered Events</h3>
<table class="table table-striped table-bordered table-hover">
<thead class="tablebackground">
<tr>
<!-- <th> User-ID #</th> -->
<th> Event Name</th>
<th> Location</th>
<th> Date</th>
<th> Time</th>
<th> UnRegister</th>
</tr>
</thead>
<tbody>
<?php
foreach ($records1 as $row1):
echo "<tr>";
//echo "<td> $row->intMemberID</td>";
//echo "<td> $row1->intEventID</td>";
echo "<td> $row1->strEventDescription</td>";
echo "<td> $row1->strLocationName</td>";
echo "<td> $row1->datDate</td>";
echo "<td> $row1->timTime</td>";
echo "<td><a class='btn btn-danger btn-sm'>Delete</a></td>";
echo "</tr>";
endforeach;
爲什麼有2個表?保存所有數據的單個表格就足夠了。只需添加一個值爲0/1或Y/N的字段。然後這將是一個簡單的事情,切換此標誌。 – jeff
這只是我的例子,我也有其他表格和其他信息 – user2398718
在程序中思考。你需要閱讀一個,刪除它,然後寫到另一個,但如果你想確保它在那裏,你可以做一個確保每個字段匹配的位置。 –