duandian2725 2016-12-30 13:39
浏览 97

隐藏表单并使用if语句

I have looked in quite a few places and cannot find the a really good example of what I need. I have a button that when submitted needs to pop up a form. I have done this in the past using the input=hidden name. However, I am using trying to use if statements instead of just a variable. I will give you the code that I have in hopes that you can help find out what exactly I am doing wrong. You can see that I am indeed using the hidden name for some but I really don't know how to incorporate that into the if statements.

if($row[status] == 0) { print "<input type='image' src='images/rework-ticket.png' alt='Rework' value='Rework' name='button' style='height:50px; width:50px; '>"; }  
            elseif($row[status] == "Rework (In Progress)") { print "<img src='images/rework-ticket.png' alt='Rework' style='height:50px; width:50px; '>"; }


            print "<td align='center'>";
            print "<form method='post' action='test2.php'>";            
            print "<input type='image' src='images/rework-ticket.png' alt='Add Rework Ticket' value='Enter Employee ID' name='button' style='height:50px; width:50px; '>";
            print "<input type='hidden' name='proceed_to_rework' value='true'>";
            print "<input type='hidden' name='invoice_number' value='$row[invoice_number]'>";
            print "<input type='hidden' name='last_name' value='$row[last_name]'>";
            print "<input type='hidden' name='status' value='$status'>";
            print "Status:";
            print "<td><select name='status' size='1'>";
            if($status != NULL) { print "<option value='$status'>$status</option>"; }
            if($status != "Parts Prep (In Progress)") { echo "<option value='Parts Prep (In Progress)'>Parts Prep (In Progress)</option>"; }
            if($status != "Parts Prep (Complete)") { echo "<option value='Parts Prep (Complete)'>Parts Prep (Complete)</option>"; }     
            if($status != "Assembly (In Progress)") { echo "<option value='Assembly (In Progress)'>Assembly (In Progress)</option>"; }
            if($status != "Assembly (Complete)") { echo "<option value='Assembly (Complete)'>Assembly (Complete)</option>"; }       
            if($status != "Finish (In Progress)") { echo "<option value='Finish (In Progress)'>Finish (In Progress)</option>"; }
            if($status != "Finish (Complete)") { echo "<option value='Finish (Complete)'>Finish (Complete)</option>"; }     
            if($status != "Plumbing (In Progress)") { echo "<option value='Plumbing (In Progress)'>Plumbing (In Progress)</option>"; }
            if($status != "Plumbing (Complete)") { echo "<option value='Plumbing (Complete)'>Plumbing (Complete)</option>"; }
            print "</form>";
            print "</td>";

I really appreciate any comments on how I can not only fix this code but improve this question.

  • 写回答

2条回答 默认 最新

  • dongyong5912 2016-12-30 13:45
    关注

    You can use the if statement as follows.

    <?php if (condition): ?>
    
        <!-- HTML here -->
        <?php if (anotherCondition): ?>
            <!-- HTML here -->
        <?php endif; ?>
        <!-- HTML again -->
    
        <?php if (anotherCondition): ?>
            <!-- HTML here -->
        <?php endif; ?>
        <!-- HTML again -->
    
    <?php endif; ?>
    

    With this way, you don't have to use that much print statements.

    Read the examples in php docs.

    评论

报告相同问题?

悬赏问题

  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了