Ok I have been working on this function to delete an item from a mysql
database and so far I have not had any success.  Here is the problem I am
having (after alot of headaches), I need to be able to associate a checkbox
to a record or a set of records... For example, page 1 queries a database
and pulls the results into a table and in that table is a form with a
checkbox for each record pulled from said database... code is here...
require '../path/to/db.php'; //connection script
$result = @mysql_query("SELECT * FROM cur_inv",$dbh) or die("Could not
execute query, please try again later");
echo "<table border=\"0\" class=\"table-body\" width=\"100%\"><form
name=\"rem_inv\" method=\"post\" action=\"done2.php3\">
<tr><td align=\"center\" colspan=\"3\"><font size=\"4\"><B>Current
Inventory</B></font><hr color=\"333333\"></td></tr>";
$count = -1;
while ($myrow = mysql_fetch_row($result)) {
$count ++;
echo "<tr><td width=\"30%\"><B>Type Of Car: </B></td><td>";
echo "</td><td><input type=\"checkbox\" name=\"id\"
echo "rest of fields in database";
echo "<tr><td><input type=\"submit\" name=\"delete\"
Now what I need to do is to have the checkbox item be associated with all
one record set.  Table structure is here....
| id | car_model | car_type | car_year | car_price | car_vin | dlr_num |
| 0 | ford           | bronco    | 1997      | 6700       | vin#       | dlr
#     |
etc. etc.
>From the first page it links to page which queries the db and deletes the
selected records... however, I am not able to get the "id" to be associated
with the records in the table... the deletion script is as follows....
require '../path/to/db.php';
$table_name = "cur_inv";
$sql = "DELETE FROM $table_name WHERE id = '$id'";
$result = mysql_query($sql,$dbh) or die(mysql_error());
print("record deleted");
If anyone has ever run into this please help... I am still fairly new to php
and mysql and there is definately something I am missing here and I think
its because I need to associate the checkbox with the id and the id field
from the database does not seem to be linked to the rest of the record in
said fields...
Thanks in advance,
And yes I do know I posted the same question yesterday... I still cannot
figure this one out.

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to