drex88669 2012-10-23 04:20
浏览 22
已采纳

如果语句问题提交表单php

I have a site in which an Admin User looks at rows of invoices which have been submitted by users, when they click on an 'Approve Invoice' button from one of these rows it will take them on the page below.

Once the Admin User approves this invoice, they hit the 'yes' radio button and submit at the bottom of the page which enters the value 'AUDITED' under the 'npc_active' column in that row. It then multiplies the quantity and points and inserts the total onto a new row in 'tally_points' (along with their user id and sales id). This is all working fine, but...

What I am trying to do, however, is make a condition in which once the sale is audited, that it can't be re-audited. ie the 'This invoice has been audited' print should show once the submission has taken place, but it isn't working.

I'm close but can't seem to figure out what the problem is. The code in which I think I am having the problem is below, the full page code is at the bottom of this post.

$str ='<form method="post" action="audit_invoice.php">
    <font style="font-size:11px;">
    <em>Is this invoice approved?<br />';
if($approved == "AUDITED") {
    $str .='Please select carefully as this action cannot be undone.</em>
    <em>Yes:</em><input type="radio" value="AUDITED" name="npc_active">  <em>No:</em>
        <input type="radio" value=" " name="npc_active"> 
        <input type="submit" name="submit" value="Submit" />
        <input type="hidden" name="submitted" value="TRUE" />
    <input type="hidden" name="id" value="' . $id . '" />
        </font>
        </form></tr>';
}
else {
    $str .='This invoice has been audited'; 
}
echo $str;

If I put the '==' before "AUDITED" it will show up with the echo 'The invoice has been audited' in each instance, if I put '=' in front of "AUDITED" it will show the yes button and submit button in each instance.

  • 写回答

1条回答 默认 最新

  • doq91130 2012-10-23 05:06
    关注

    @AdamMC the = operator is only used when assigning data.

    You are comparing a data, therefore you are correct when using ==

    if($approved == "AUDITED") 
    

    I would like to request what exactly your $approve variable contains. As of right now I can only make an assumption that this code implies

    if invoice is approved it would equal audited which then would trigger it to echo "this invoice has been audited"

    To stackoverflow users: please do not downvote, I cannot comment because my reputation does not permit it. Just trying to help

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 ARIMA模型时间序列预测用pathon解决
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序,怎么查看客户esp32板子上程序及烧录地址
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)