set variable to go outside scope
| From: | Mike Tuller | Date: | Thu, 05 Jan 2006 19:22:12 +0000 |
| Subject: | set variable to go outside scope | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-228227@lists.php.net to get a copy of this message | ||
I have a table listing items in a database, and have a delete button next to each item, and I want to be able to click on the delete and delete only that record in the database and then reload the page where it would display the updated information. Here is part of the code I have.
echo "</table>";
echo "
<br />
<form action=".$_SERVER['PHP_SELF']." method=\"post\" name=\"addrange\">
<table class=\"nolist\">
<tr>
<td>Add Range: $row[id]</td>
<td><input type=\"text\" name=\"name\" size=\"53\" tabindex=\"9\" /></td>
<td align=\"right\"><input type=\"submit\" name=\"addRange\" value=\"Add Range\" /></td>
</tr>
</table>
</form>";
}
elseif (isset($_POST['deleteRange']))
{
$query = "delete from district.ip_range where id = $row[id]";
mysql_query($query, $link) or die (mysql_error());
echo "Record ".$row[id]." has beed deleted.";
}
They key I am using to find the record I want to delete is the the $row[id], but that is out of the scope of where the variable is set. Is there a way to set a variable so that it goes outside the scope?