0

I'm trying to figure out how to make this code snippet display the value or the button but not both. As you'll see there is a button for "Call_Attempt_One". I'm trying to have it only display when there is no value in the field but have the field value displayed when there is a value and have the button disappear.

Suggestions?? Thanks!

<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."'");
    }
}   
new2programming
  • 257
  • 1
  • 9
  • Kindly clarify a little bit you are saying "when there is no value" you are referring to which value? – saqibahmad May 12 '15 at 21:10
  • Sure, I mean in psuedo code if callattemptone field in database is empty show button. If callattemptone field already has value display that value and not the button – new2programming May 13 '15 at 02:04
  • use following condition if($row['Call_Attempt_One'] ==""){// show button code}else{//echo $row['Call_Attempt_One']} for null please read this http://stackoverflow.com/questions/8236354/php-is-null-or-empty – saqibahmad May 13 '15 at 14:05

1 Answers1

-1

here is the code that I found to work in my question above. I fixed it myself and replaced these lines

if(isset($_POST['formDelete']))
{
    if(isset($_POST['ID']) && !empty($_POST['ID']))
    {
        $deleteID = $_POST['ID'];
        $result = mysql_query("DELETE FROM Project_Submissions WHERE ID ='".$deleteID."'");
    }
}   
new2programming
  • 257
  • 1
  • 9
  • 1
    While this may answer the question it’s always a good idea to put some text in your answer to explain what you're doing. Read [how to write a good answer](http://stackoverflow.com/help/how-to-answer). – Jørgen R May 13 '15 at 13:42
  • this is not a relevant to the answer – saqibahmad May 13 '15 at 14:08