おはよう友達!
2つのテーブルに同時にデータを挿入しようとしています。最初の条件IFは問題ありませんが、2番目の条件ELSEは問題ありません。以下に挿入コードを含めます。ELSEで試してみましたが、IFでもELSEIFで試してみましたが、機能しません。
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
if(visiting_club != '1'){
$panel = "INSERT INTO panel (GF, GC, binant_club, visitor_club, id_competitions, status, status)
VALUES ('$score1','$scor2','$mandant_club','$visitor_club',
'$id_competitions','$id_states','$situation')";
}else{
$panel = "INSERT INTO panel
(GC, GF, mandant_club, visitor_club,
id_competitions, status, status)
VALUES ('$score1','$scor2','$mandant_club',
'$visitor_club','$id_competitions',
'$id_states','$situation')";
}
ご静聴ありがとうございました。
あなたのコードは巨大な間違ったデータと欠けている変数を持っています
この変数@ $ visitor club = $ _POST ['visitor_club']; @ $ visitor_club
変数@ $ history = $ _POST ['history']を宣言します。しかし、[対決]テーブルにデータを挿入するときに$ historia変数を呼び出します。
テーブル[対立]にデータを挿入するために["]二重引用符を開始しますが、[']単一引用符を終了します。
テーブル[対決]の挿入コード。[11]列名を宣言しますが、[12]列値を宣言します。したがって、データ挿入コードに同じ列名と値を入力する必要があります。
[パネル]テーブルにデータを挿入すると、コードは次のようになります
INSERT INTOパネル(GF、GC、binant_club、visitor_club、id_competitions、status、status)
ここで最後の2つの列(ステータス、ステータス)の名前は同じです。同じ列名を使用してデータを挿入することはできません。
注:MySQLで挿入コードを作成する場合。PHP MyAdminに移動し、データベースを選択します>>テーブルを選択します>>挿入をクリックします>>ダミーデータを挿入します>> MySQLがPHPの自動挿入コードを生成します 列の値を変更して、挿入データにこのコードを使用します。
ありがとう。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加