sql查询不从数组中将数据插入数据库表

时间:2018-04-28 14:31:38

标签: php sql

下面的代码应该从personprofile表中将数据(名字,姓名,姓氏,医疗保险)插入organandtissuedonationcommittee表以及"器官捐赠" if prioritylvl == 1和()中的数据相同以及" pending"当prioritylvl == 2/3时 请帮助我,我无法找出我做错了什么。这是代码

    // check the prioritylvl if 1 insert organstatus as transplant completed if 2 or 3 then organstatus as pending
$sqlpersonprofile= "SELECT firstname,fathername,lastname,medicalinsurance,prioritylvl,admissionreason FROM personprofile";
$patients=  mysqli_query($link,$sqlpersonprofile);
$processpriority= mysqli_fetch_assoc($patients);
if($processpriority['prioritylvl'] == 1 && $processpriority['admissionreason'] == 5 ){
//dont forget to add the organ status
    $sqlcommittee= 'INSERT INTO organandtissuedonationcommittee(firstname,fathername,lastname,insurance,organstatus)  
    VALUES("$processpriority['firstname']","$processpriority['fathername']","$processpriority['lastname']","$processpriority['medicalinsurance']","Organ donated")';
    $committee = mysqli_query($link, $sqlcommittee);

        if(!$committee){
                echo 'Not inserted';
            }
}
if($processpriority['prioritylvl'] == 2 || $processpriority['prioritylvl'] == 3 && $processpriority['admissionreason'] == 5 ){
//dont forget to add the organ status
    $sqlcommittee= 'INSERT INTO organandtissuedonationcommittee(firstname,fathername,lastname,insurance,organstatus)  
    VALUES("$processpriority['firstname']","$processpriority['fathername']","$processpriority['lastname']","$processpriority['medicalinsurance']","Pending")';
    $committee = mysqli_query($link, $sqlcommittee);

        if(!$committee){
                echo 'Not inserted';
            }
}

0 个答案:

没有答案