第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 IF 同時插入兩個表

使用 IF 同時插入兩個表

PHP
牧羊人nacy 2023-07-01 15:39:07
我試圖同時將數(shù)據(jù)插入兩個表中。第一個條件 IF 可以,但第二個條件 ELSE 不行。我在下面添加了我的插入代碼。我已經(jīng)嘗試過使用 ELSE、ELSEIF 甚至 IF,但它不起作用。if (isset($_POST['save')) {    if (@$_POST['id_confrontations'] == "") {        @$description = $_POST['description'];        @$dt_confrontation = $_POST['dt_confrontation'];        @$id_competitions = $_POST['id_competitions'];        @$id_stages = $_POST['id_stages'];        @$score1 = $_POST['score1'];        @$score2 = $_POST['score2'];        @$mandant_club = $_POST['mandant_club'];        @$visitor club = $_POST['visitor_club'];        @$situation = $_POST['situation'];        @$phase = $_POST['phase'];        @$id_trainers = $_POST['id_trainers'];        @$history = $_POST['history'];        //saves the record in the "confrontations" table - In this case insertion is perfect        $confrontations = "INSERT INTO confrontations                             (description, dt_confrontation, id_competitions,                             stadiums_id, score1, scoring2, binder_club,                             situation, stage, id_trainers, history)                 VALUES ('$description','$dt_confrontation','$id_competitions',                        '$id_estadios','$score1','$score2',                        '$mandant_club','$visitor_club','$situation',                        '$stage','$id_trainers','$historia')';        //saves the record in the "panel" table - In IF insertion is perfect, but in ELSE it inserts as if it were IF        //In the IF rule the mandating_club would be == '1', so the GF would receive the score1 and the GC would receive the score2        //In the ELSE rule the visiting_club would be == '1', so the GC would receive the score1 and the GF would receive the score2感謝大家的關(guān)注和建議。
查看完整描述

1 回答

?
白衣非少年

TA貢獻(xiàn)1155條經(jīng)驗 獲得超0個贊

您的代碼有大量錯誤數(shù)據(jù)和缺少變量

  1. 該變量@$visitorclub = $_POST['visitor_club']; 應(yīng)該@$visitor_club

  2. 您聲明變量 @$history = $_POST['history']; 但是當(dāng)將數(shù)據(jù)插入 [confrontations] 表時,您會調(diào)用 $historia 變量。

  3. 您以 ["] 雙引號開始將數(shù)據(jù)插入表 [confrontations],但以 ['] 單引號結(jié)束。

  4. 您的表 [對抗] 的插入代碼。您聲明 [11] 列名稱,但聲明 [12] 列值。因此,您現(xiàn)在應(yīng)該將相同的列名稱和值添加到數(shù)據(jù)插入代碼中。

  5. 當(dāng)您將數(shù)據(jù)插入[面板]表時,您的代碼如下

    插入面板(GF、GC、binant_club、visitor_club、id_competitions、狀態(tài)、狀態(tài))

這里最后兩列(狀態(tài),狀態(tài))名稱相同。您不能使用相同的列名插入數(shù)據(jù)。

注意:如果你想用MySQL創(chuàng)建插入代碼。轉(zhuǎn)到 PHP MyAdmin 并選擇您的數(shù)據(jù)庫 >> 選擇您的表 >> 單擊插入 >> 插入虛擬數(shù)據(jù) >> 現(xiàn)在 MySQL 為 PHP 生成自動插入代碼。使用此代碼通過更改列值插入數(shù)據(jù)。


查看完整回答
反對 回復(fù) 2023-07-01
  • 1 回答
  • 0 關(guān)注
  • 129 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號