如果表单字段不为空,则更新多条记录

问题描述 投票:0回答:1

如果有人上传新文件,我会尝试更新数据库中的多条记录。由于某种原因,该页面将无法工作。我只是看到白屏并且没有进行任何更新。任何建议都会很棒。谢谢

$district_data = new WA_MySQLi_RS("district_data",$sdpc_i,1);
$district_data->setQuery("SELECT *, data.softwareID as thesoftwareID FROM data left join software on data.softwareID = software.softwareID left join districts on districts.districtID = data.districtID where dataID = ?");
$district_data->bindParam("i", "".(isset($_GET['dataID'])?$_GET['dataID']:"")  ."", "-1"); //colname
$district_data->execute();
$softwareID = $district_data->getColumnVal("thesoftwareID");
$originator = $district_data->getColumnVal("originator");

if ($_GET['state'] == 'NY' and $originator == 'Y') {
$newfile = new WA_MySQLi_RS("newfile",$sdpc_i,0);
$newfile->setQuery("SELECT supplemental_info FROM data WHERE dataID = ?");
$newfile->bindParam("i", "".$_GET['dataID']  ."", "-1"); //colname
$subscribers = new WA_MySQLi_RS("subscribers",$sdpc_i,0);
$subscribers->setQuery("SELECT dataID FROM data WHERE originating_dataID = ?");
$subscribers->bindParam("i", "".$_GET['dataID']  ."", "-1"); //colname
$subscribers->execute();
for($i=0;$i<count($subscribers->getColumnVal("dataID"));$i++){
        $supplemental_info = $new_file->getColumnVal("supplemental_info");
        $dataID = $subscribers->getColumnVal("dataID")[$i];
        if($supplemental_info!==''){
    $sql="UPDATE data set supplemental_info = $supplemental_info where dataID = $dataID";
            $stmt=$sdpc_i->prepare($sql);
            $stmt->execute();
            //echo '<div class="alert alert-success" role="alert">Submitted Successfully</div>';
        
        }}}


php forms mysqli
1个回答
0
投票

开始工作了

$UpdateQuery = new WA_MySQLi_Query($sdpc_i);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "`data`";
$UpdateQuery->bindColumn("supplemental_info", "s", "".($WA_DFP_UploadStatus["WA_UploadResult4"]["WA_UploadResult4_4"]["serverFileName"]) ."", "WA_IGNORE");
$UpdateQuery->addFilter("originating_dataID", "=", "i", "".($dataID)  ."");
  $UpdateQuery->execute();
  $UpdateGoTo = "";
  if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
  $UpdateQuery->redirect($UpdateGoTo);

谢谢大家

© www.soinside.com 2019 - 2024. All rights reserved.