Re: Editing a Database
| From: | callen | Date: | Wed, 12 Jul 2000 06:23:23 +0000 |
| Subject: | Re: Editing a Database | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-6078@lists.php.net to get a copy of this message | ||
Jeff Wilhelm wrote:
> So basically I want the entire table listed (simple loop) and the ability to
> delete any row from the database. I have a pretty good idea of how to do it,
> but if someone could give me a little help it'd be great.
>
> Thanks!
> -Jeff
In pseudocode:
Connect to db,
while_getting_data_from_query{
Use a form field (checkbox would work)
print to the page each instance of product_name within checkbox_field
having the same name such as a[] with a value of product_id
something like this:
<input type=\"checkbox\" name=\"a[]\"
value=\"$row->Product_id\">
end_while_condition
}
$a will show up on whatever page you set your action to in form
statement.
Then cycle thru it:
if (is_array($a)) {
while ( list($key, $val) = each ( $a ) )
{
$query = "delete from table where ID=$value";
$result = MYSQL_QUERY($query);
}
}
so if you checked 5 boxes you will get 5 deletes, of course this is far
from done. But its an idea for you...
Good Luck!
--
Christopher C.M. Allen
http://design.driver8.org/
Email: callen@driver8.org
Cell : 1.715.821.4006