RE: [PHP-DB] Parse Error
| From: | Gurhan Ozen | Date: | Thu, 21 Feb 2002 18:47:43 +0000 |
| Subject: | RE: [PHP-DB] Parse Error | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-17156@lists.php.net to get a copy of this message | ||
Just change
echo "</td><td><input type=\"checkbox\" name=\"cars\"
value=\"checkbox\">remove</td></tr>\n";
to
echo "</td><td><input type=\"checkbox\" name=\"cars\"
value=\"".$myrow[id]."\">remove</td></tr>\n";
Gurhan
-----Original Message-----
From: jas [mailto:jlgerfen@hotmail.com]
Sent: Thursday, February 21, 2002 1:33 AM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Parse Error
Could you maybe give me an example of how to associate the checkbox with the
id? Thanks again,
Jas
"Gurhan Ozen" <c-gurhan.ozen@wcom.com> wrote in message
news:NEBBJFKICMBBMAOHJDFOIEHMCOAA.c-gurhan.ozen@wcom.com...
> Ok then it sure will not work.. because you have :
>
> "DELETE FROM $table_name WHERE $cars
>
=\"$car_type\",\"$car_model\",\"$car_year\",\"$car_price\",\"$car_vin\",\"$d
> lr_num\"");
>
> 1- $cars is set to the value "checkbox" which doesn't exist in your test
> table
> 2- The end of the statement ....$dlr_num\""); is not right , that
> parenthesis isn't supposed to be there
> 3- The delete statement is wrong...You are storing all that info in the
> separate fields but you are giving all combined as a condition in only one
> field ($cars).
> 3- Rewrite your delete statement to delete the rows identified by the id
> column as "DELETE FROM $table WHERE id ='id'"; Of course in the page where
> you list the cars to be deleted associate each checkbox with the car's id.
>
> Hope this helps..
>
> Gurhan
>
>
> -----Original Message-----
> From: jas [mailto:jlgerfen@hotmail.com]
> Sent: Thursday, February 21, 2002 1:02 AM
> To: php-db@lists.php.net
> Subject: Re: [PHP-DB] Parse Error
>
>
> Here is the dump for the cars table...
> test (
> id varchar(30) NOT NULL auto_increment,
> car_type varchar(30),
> car_model varchar(30),
> car_year varchar(15),
> car_price varchar(15),
> car_vin varchar(25),
> dlr_num varchar(25),
> PRIMARY KEY (id),
> KEY id (id)
> test VALUES ('1', 'Ford', 'Bronco', '1969',
> '4500', 'vin897655', 'none');
>
> Sorry about that... still a bit of a newbie here. =)
> Jas
>
> "Gurhan Ozen" <c-gurhan.ozen@wcom.com> wrote in message
> news:NEBBJFKICMBBMAOHJDFOMEHKCOAA.c-gurhan.ozen@wcom.com...
> > Jas..
> > First of all you don't have the variable $cars assigned..
> > Second of all, we still don't know what the "test" table looks like?
Does
> it
> > only have one column with all the infos about cars populated in it???
> >
> > Gurhan
> >
> >
> > -----Original Message-----
> > From: jas [mailto:jlgerfen@hotmail.com]
> > Sent: Thursday, February 21, 2002 12:48 AM
> > To: php-db@lists.php.net
> > Subject: Re: [PHP-DB] Parse Error
> >
> >
> > Here is the code from the file that queries the db and pulls the current
> > contents of the db and provides a check box form for each record to
delete
> > the items in the db. I dont know if this will help but like I said
before
> > any insight would be great. Thanks in advance.
> > Jas
> >
> > <?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>";
> > ?>
> >
> > After this file is pulled and the user selects which record to delete it
> > jumps to the other snippit of code in done2.php3 which is
> >
> > > > $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.
> > > >
> > > > Any insight would be great... thanks again.
> > > > Jas
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > PHP Database Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit:
> > > > http://www.php.net/unsub.php
> > > >
> > >
> > >
> > >
> > > --
> > >
> > >
> > >
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php