我正在尝试使用PHP。这是我的func.php
function returnBlankStylist(){
$sql=mysql_query("SELECT * FROM `".$dbn."`.`stylist` WHERE `stylist`.`customer_id`='1'");
if (mysql_affected_rows()==0) {
return false;
} else {
return true;
}
}
这是我的page.tpl
<?php if (returnBlankStylist==false){?>
<div class="center graybox"> Please enjoy this discount since this you have never filled out a query before</div>
<? }?>
如果客户Id 1存在,则显示该消息,如果客户Id 1不存在则显示消息?
答案 0 :(得分:4)
<?php if (returnBlankStylist() == false) : ?>
<div class="center graybox">
Please enjoy this discount since this you have never filled out a query before
</div>
<? endif; ?>
或
<?php if (!returnBlankStylist()) : ?>
<div class="center graybox">
Please enjoy this discount since this you have never filled out a query before
</div>
<? endif; ?>
或
<?php if (returnBlankStylist() == false) { ?>
<div class="center graybox">
Please enjoy this discount since this you have never filled out a query before
</div>
<? } ?>
答案 1 :(得分:1)
你错过了父母身份..
if(returnBlankStylist()==false){
//your code...
}
希望它适合你
答案 2 :(得分:1)
请将您的代码if (mysql_affected_rows()==0)
替换为if (mysql_num_rows()==0);
试试这个:
<?php if (!returnBlankStylist()){?>
<div class="center graybox"> Please enjoy this discount since this you have never filled out a query before</div>
<? }?>