【发布时间】:2015-05-12 21:05:06
【问题描述】:
我试图弄清楚如何让这段代码 sn-p 显示值或按钮,但不能同时显示两者。如您所见,有一个“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."'");
}
}
【问题讨论】:
-
请澄清一下您所说的“当没有价值时”您指的是哪个价值?
-
当然,我的意思是在伪代码中,如果数据库中的 callattemptone 字段是空的显示按钮。如果 callattemptone 字段已经有值显示该值而不是按钮
-
使用以下条件 if($row['Call_Attempt_One'] ==""){// 显示按钮代码}else{//echo $row['Call_Attempt_One']} 为空请阅读此stackoverflow.com/questions/8236354/php-is-null-or-empty