PHP - Unable to find variable
<p>I am trying to implement a UI which the user would be able to select entries by selecting checkboxes to delete them from the database. However, while everything looks fine and able to display, there is an error saying <code>Notice: Undefined variable: delete in /opt/uiForm.php on line 154</code> whereas <code>$delete</code> is not readable. I am following the example given <a href="http://www.phpeasystep.com/mysql/8.html" rel="nofollow">here</a>. Am I missing anything?</p>

<pre><code>&lt;body&gt;

&lt;form name="frm" method="get" action="doSubmit();"&gt;


&lt;?php

// Connect to server and select database.
 mysql_connect("127.0.0.1:3306", "root", "")or die("cannot connect"); 
 mysql_select_db("PushApplication")or die("cannot select DB");

$sql="SELECT * FROM Device";
 $result=mysql_query($sql);

$count=mysql_num_rows($result);

?&gt;
 &lt;table width="400" border="0" cellspacing="1" cellpadding="0"&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;form name="form1" method="post" action=""&gt;
 &lt;table width="400" border="0" cellspacing="1" bgcolor="#CCCCCC"&gt;

 &lt;tr&gt;
 &lt;td align="center" bgcolor="#FFFFFF"&gt;#&lt;/td&gt;
 &lt;td align="center" bgcolor="#FFFFFF"&gt;&lt;strong&gt;ID&lt;/strong&gt;&lt;/td&gt;
 &lt;td align="center" bgcolor="#FFFFFF"&gt;&lt;strong&gt;DeviceID&lt;/strong&gt;&lt;/td&gt;
 &lt;td align="center" bgcolor="#FFFFFF"&gt;&lt;strong&gt;DeviceType&lt;/strong&gt;&lt;/td&gt;
 &lt;td align="center" bgcolor="#FFFFFF"&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/td&gt;
 &lt;td align="center" bgcolor="#FFFFFF"&gt;&lt;strong&gt;OS_Version&lt;/strong&gt;&lt;/td&gt;
 &lt;td align="center" bgcolor="#FFFFFF"&gt;&lt;strong&gt;Status&lt;/strong&gt;&lt;/td&gt;

 &lt;/tr&gt;
&lt;?php
 while($rows=mysql_fetch_array($result)){
 ?&gt;
 &lt;tr&gt;
 &lt;td align="center" bgcolor="#FFFFFF"&gt;&lt;input name="checkbox[]" type="checkbox" id="checkbox[]" value="&lt;? echo $rows['ID']; ?&gt;"&gt;&lt;/td&gt;
 &lt;td bgcolor="#FFFFFF"&gt;&lt;? echo $rows['ID']; ?&gt;&lt;/td&gt;
 &lt;td bgcolor="#FFFFFF"&gt;&lt;? echo $rows['DeviceID']; ?&gt;&lt;/td&gt;
 &lt;td bgcolor="#FFFFFF"&gt;&lt;? echo $rows['DeviceType']; ?&gt;&lt;/td&gt;
 &lt;td bgcolor="#FFFFFF"&gt;&lt;? echo $rows['Description']; ?&gt;&lt;/td&gt;
 &lt;td bgcolor="#FFFFFF"&gt;&lt;? echo $rows['OS_Version']; ?&gt;&lt;/td&gt;
 &lt;td bgcolor="#FFFFFF"&gt;&lt;? echo $rows['Status']; ?&gt;&lt;/td&gt; 
 &lt;/tr&gt;
&lt;?php
 }
 ?&gt;
 &lt;tr&gt;
 &lt;td colspan="7" align="center" bgcolor="#FFFFFF"&gt;&lt;input name="delete" type="submit" id="delete" value="Delete"&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;?php
// Check if delete button active, start this
 if($delete){
 for($i=0;$i&lt;$count;$i++){
 $del_id = $checkbox[$i];
 $sql = "DELETE FROM Device WHERE ID='$del_id'";
 $result = mysql_query($sql);
 }

// if successful redirect to delete_multiple.php 
 if($result){
 echo "&lt;meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\"&gt;";
 }
 }
 mysql_close();
 ?&gt;
 &lt;/table&gt;
 &lt;/form&gt;
 &lt;/td&gt;
 &lt;/tr&gt;
 &lt;/table&gt;

&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
