将一行添加到另一个表时删除该行


Remove one row when it is added to different table

我有两个表

已注册事件和事件,但是我想显示当按下按钮时,它将事件从事件中移除到已注册事件中。但是我无法删除事件本身我可以隐藏它,使它不显示在网页上的表??

我正在使用CodeIgniter

![Cassey fields的分级刮刮赛在两个表中][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);
}
<<p> 视图/strong>
        <!-- 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));