我试图获得以下查询:
如果有值为B,则存在A的值和B的值如果存在值,则如果存在值,则为或者。做什么
if((isset($_POST['A'], $_POST['B'])) OR !empty($_POST['B']) OR !empty($_POST['A']))
{
echo "there is something:" . $_POST['B'] . ", " . $_POST['A'];
}
else
{
echo "its empty<br />";
}
当其中一个字段中的某个值正常工作时,但当我们为空时,两个字段仍然显然存在。
葡萄酒可能与自动完成有关吗?
$checkVIN1 = mysql_query("SELECT vhl_vin FROM vhldescription");
$num_rows = mysql_num_rows($checkVIN1);
$i = 0;
echo "<script>$(function() {var availableTags = [";
while($checkVIN2 = mysql_fetch_array($checkVIN1, MYSQL_ASSOC)) { $i++; echo "\"" . <br />$checkVIN2['vhl_vin'] . "\",";
if ($i == ($num_rows)) { echo "\"" . $checkVIN2['vhl_vin'] . "\""; } }
echo "];$( \"#tags\" ).autocomplete({source: availableTags});});</script>";
<input id="tags" name="A" class="le-input">
答案 0 :(得分:0)
这个怎么样?
<?php
$a;
$b;
if((isset($a) or isset($b)) and !(empty($a) or empty($b))){
echo "do something";
}else{
echo "do nothing";
}
答案 1 :(得分:0)
尝试将代码更改为:
$postVars = array('A', 'B');
$things = array();
foreach($postVars as $postVar) {
if( isset($_POST[$postVar]) && !empty($_POST[$postVar]) )
{
$things []= $_POST[$postVar];
}
}
if( empty($things) ) {
echo "it's empty<br />";
} else {
echo "there is something: "
. join(', ', array_map(function($str) {
return htmlspecialchars($str, ENT_NOQUOTES, 'UTF-8');
},
$things)) . '.';
}