最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用 IF 同時(shí)插入兩個(gè)表

使用 IF 同時(shí)插入兩個(gè)表

PHP
牧羊人nacy 2023-07-01 15:39:07
我試圖同時(shí)將數(shù)據(jù)插入兩個(gè)表中。第一個(gè)條件 IF 可以,但第二個(gè)條件 ELSE 不行。我在下面添加了我的插入代碼。我已經(jīng)嘗試過(guò)使用 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)驗(yàn) 獲得超0個(gè)贊

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

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

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

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

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

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

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

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

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


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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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