gpt4 book ai didi

php - 添加到不同表时删除一行

转载 作者:行者123 更新时间:2023-11-29 22:25:18 25 4
gpt4 key购买 nike

我有 2 张 table

注册事件和事件,但我想显示当按下按钮时,它将事件从事件中删除到注册事件中。但我无法删除事件本身我可以隐藏它,这样它就不会出现在网页的表格中吗?

我正在使用 CodeIgniter

![Cassey fields 的 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;
}

Controller

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>&nbsp;&nbsp;Meet race ID</th>
<th>&nbsp;&nbsp;Event Name</th>
<th>&nbsp;&nbsp;Location</th>
<th>&nbsp;&nbsp;Date</th>
<th>&nbsp;&nbsp;Time</th>
<th>&nbsp;&nbsp;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>&nbsp;&nbsp;User-ID #</th> -->
<th>&nbsp;&nbsp;Event Name</th>
<th>&nbsp;&nbsp;Location</th>
<th>&nbsp;&nbsp;Date</th>
<th>&nbsp;&nbsp;Time</th>
<th>&nbsp;&nbsp;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;

最佳答案

尽管事实上你可以更容易地完成这件事,但你可以尝试像这样扩展你的第一个查询 - 如果我理解正确的话:

$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));

关于php - 添加到不同表时删除一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30316310/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com