仅当字段中没有值时显示按钮,否则显示值

时间:2015-05-12 21:05:06

标签: php forms submit

我试图弄清楚如何让这段代码显示值或按钮,但不能同时显示两者。正如您所看到的,有一个按钮,用于" Call_Attempt_One"。我试图让它仅在字段中没有值时显示,但是当有值并且按钮消失时显示字段值。

建议??谢谢!

<td style='font-size:12px;width:500px;'><div style=\"overflow-x:auto; max-height:100px\">{$row['Project_Description']}</div></td>
<td style='font-size:12px;'><center>{$row['Restoration_Decision_Matrix']}</center></td>
<td style='font-size:12px;'><center>

    <form action='".$_SERVER['PHP_SELF']."' method='post'>
    <input type='hidden' id='ID' name='ID' value='{$row['ID']}' />
    <input type='submit' name='formCalledOne' id='formCalledOne' value='Called' />
    </form>
{$row['Call_Attempt_One']}

</center></td>
<td style='font-size:12px;'><center><button type=\"submit\" form=\"form1\" value=\"Submit\">Called</button></center></td>
<td style='font-size:12px;'><center><button type=\"submit\" form=\"form1\" value=\"Submit\">Called</button></center></td>
<td style='font-size:12px;'><center><button type=\"submit\" form=\"form1\" value=\"Submit\">Emailed</button></center></td>
<td style='font-size:12px;'><center>Text Area</center></td>
<td style='font-size:12px;'><center>{$row['Received_Date']}</center></td>
<td style='font-size:12px;'><center>

    <form action='".$_SERVER['PHP_SELF']."' method='post'>
    <input type='hidden' id='ID' name='ID' value='{$row['ID']}' />
    <input type='submit' name='formDelete' id='formDelete' value='Delete' />
    </form>


</center></td>
</tr>";

}

//Check to see if delete button is pressed
if(isset($_POST['formDelete']))
{
    if(isset($_POST['ID']) && !empty($_POST['ID']))
    {
        $ID = $_POST['ID'];
        $result = mysql_query("DELETE FROM Project_Submissions WHERE ID ='".$ID."'");
    }
}   

1 个答案:

答案 0 :(得分:-1)

这是我在上面的问题中找到的代码。我自己修理了它并替换了这些行

if(isset($_POST['formDelete']))
{
    if(isset($_POST['ID']) && !empty($_POST['ID']))
    {
        $deleteID = $_POST['ID'];
        $result = mysql_query("DELETE FROM Project_Submissions WHERE ID ='".$deleteID."'");
    }
}