我有2张桌子
已注册的事件和事件,但我希望在按下按钮时显示它将事件中的事件移除到已注册的事件中。 但我无法删除事件本身 我可以隐藏它,以便它显示在网页上的表格中吗?
我正在使用CodeIgniter
![Cassey领域的Graded Scratch Races事件在两个表格中] [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;
答案 0 :(得分:0)
尽管你可以更容易地做到这一点,你可以尝试扩展你的第一个查询 - 如果我理解正确的话:
$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->join('tblRegistration as reg', 'reg.intMeetRaceID = met.intMeetRaceID', 'left');
$this->db->where(array("met.intMeetRaceID" => NULL));