Re: Deleting records...
| From: | jas | Date: | Wed, 20 Feb 2002 05:35:36 +0000 |
| Subject: | Re: Deleting records... | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-17095@lists.php.net to get a copy of this message | ||
I forgot to include the error message I am recieving when trying to remove
records using the check box.
Parse error: parse error in /path/to/php/done2.php3 on line 22
Thanks in advance.
Jas
"Jas" <jlgerfen@hotmail.com> wrote in message
news:20020220172040.25341.qmail@pb1.pair.com...
> Ok I am trying to delete records from a database using an html form. I
have
> 2 files, file one = remove.php3 which queries the database table and
> displays the current contents. Code is as follows.
> <?php
> require '../scripts/db.php';
> $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>";
> printf(mysql_result($result,$count,"car_type"));
> echo "</td><td><input type=\"checkbox\" name=\"cars\"
> value=\"checkbox\">remove</td>
> </tr>\n";
> echo "<tr><td width=\"30%\"><B>Model Of Car:
> </B></td><td>";
> printf(mysql_result($result,$count,"car_model"));
> echo "</td></tr>\n";
> echo "<tr><td width=\"30%\"><B>Year Of Car:
> </B></td><td>";
> printf(mysql_result($result,$count,"car_year"));
> echo "</td></tr>\n";
> echo "<tr><td width=\"30%\"><B>Price Of Car:
> </B></td><td>$";
> printf(mysql_result($result,$count,"car_price"));
> echo "</td></tr>\n";
> echo "<tr><td width=\"30%\"><B>VIN Of Car:
> </B></td><td>";
> printf(mysql_result($result,$count,"car_vin"));
> echo "</td></tr><tr><td colspan=\"3\"><hr
> color=\"333333\"></td></tr>\n";
> }
> echo "<tr><td><input type=\"submit\" name=\"delete\"
> value=\"delete\"></td></tr></form></table>";
> ?>
> Once it queries the database it gives the user an option to check the
> checkbox and delete that record. Here is the done2.php3 page that
actually
> contains the delete sql statement....
> $db_name = "test";
> $table_name = "inventory";
> $connection = @mysql_connect("localhost", "root", "password") or
> die
("Could
> not connect to database. Please try again later.");
> $db = @mysql_select_db("$db_name",$connection) or die ("Could not select
> database table. Please try again later.");
> $sql = "DELETE FROM $table_name WHERE $cars =
>
\"$car_type\",\"$car_model\",\"$car_year\",\"$car_price\",\"$car_vin\",\"$dl
> r_num\"");
> $result = @mysql_query($sql, $connection) or die ("Could not execute
query.
> Please try again later.");
>
>