我有一个下拉列表,其中包含来自状态列的“已处理”,“未发布”,“付费”。我想在选项中添加扫描副本,但这是来自其他列扫描副本。我将采取什么措施让它发挥作用?这是我的代码。
$searchstat = (!empty($_REQUEST['optstat']) ? $_REQUEST['optstat'] : '%');
$vartxtsummryNo = (!empty($_REQUEST['txtsummryNo']) ? $_REQUEST['txtsummryNo'] : '%');
if($searchstat!="%"){
$vartxtsummryNo="%";
}
$sc=ScanCopy();
$scan_copy=array("Scanned Copy");
$astatus = array("Processed","Unreleased","Paid");
$astatus = array_merge($astatus, $scan_copy);
if ($astatus[$scan_copy]) { $sc; }
foreach ($astatus as $stat){
$optstatus .= "<option " . ($searchstat == $stat ? "selected" : "") . ">$stat</option>";
}
这是选择扫描副本时获取数据的查询。
function ScanCopy() {
$sql2="SELECT * FROM payment_summary_log WHERE Scanned_copy IS NOT NULL ORDER BY Date_Created";
$mesconn = dbConnect();
$messtmt1 = $mesconn->prepare($sql2);
$data = $messtmt1->fetchAll(PDO::FETCH_ASSOC);
$mesconn=null;
return $data;
}
以下是搜索框和下拉列表的结构。
echo "<form method=get name='" . $_REQUEST['option'] . ".form' autocomplete='off'>";
echo "<input type='hidden' name='option' value='" . $_REQUEST['option'] . "'>";
echo "<table class=normal2 style='font-size:0.6em;'>";
echo "<h2 style='color:blue'>Payment Summary Tracking</h2><hr>";
echo "<tr><th>Payment Summary No. :</th><td colspan=2><input type=text name='txtsummryNo' value='".$vartxtsummryNo."'> <input type=submit name='bnt_setdate' value='Find'></td>";
echo "<tr><th>Status :</th><td colspan=2><select name=optstat onchange='document.forms[\"" .$_REQUEST['option'] . ".form\"].submit();'>$optstatus</select></td></tr>";
echo "</tr></table></form>";
echo "<h2></h2><hr>";
答案 0 :(得分:0)
$data
函数返回有效的ScanCopy()
,此函数目前尚未发生第二,您需要将scancopy函数的返回值合并到$astatus
数组,并将其添加到下拉列表中:
$astatus = array_merge($astatus, $scan);
请在合并前相应地修改数组,我刚刚提供了提示,详情请见下方: