Dave,
First, you need a "SELECT" tags.
print "";
$deloptions_sql = "select * from $tbn2";
$delresult = mysql_query($deloptions_sql, $con) or
die("error:".mysql_error());
while ($listdelrows = mysql_fetch_array($delresult) ){
$name2 = $listdelrows[name];
$id2 = $listdelrows[id];
$del_list .="$name2";
}
print "";
Second, are you trying to do the above and this in one script?
if($delproduct){
$del_sql ="delete from $tbn2 where id = '$id2' and name ='$name2'";
$del_res = mysql_query($del_sql,$con) or die ("Unable to Delete
Product");
$delproductmsg = "Deleted $name2 from $p_cat_name";
}
if so, you need some more structure...
Show more of your script instead of what YOU think we ought to see. You
have left out big chunks. I promise, we won't steal your coding for our own
nefarious uses
rick
-Original Message-
From: Dave Carrera [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 14, 2002 11:04 AM
To: php List
Subject: [PHP-DB] Deleting from a select list ? :-(
Hi All,
I have this code creating a list in a select box.
All works ok, I get my list BUT and a NIG BUT.
When I select an item to delete it only ever deletes from the last
record to the top.
Err why ?
I think all my code is in the right order but obviously not.
Can anyone throw some light on this.
As always thanks for past and future help
Dave C :-)
--MY CODE STARTS HERE ---
$deloptions_sql = "select * from $tbn2";
$delresult = mysql_query($deloptions_sql, $con) or die("error:
".mysql_error());
$delrows = mysql_num_rows($delresult);
for ($i = 0; $i < $delrows; $i++) {
$listdelrows = mysql_fetch_array($delresult);
$name2 = $listdelrows[name];
$id2 = $listdelrows[id];
$del_list .="$name2";
}
if($delproduct){
$del_sql ="delete from $tbn2 where id = '$id2' and name ='$name2'";
$del_res = mysql_query($del_sql,$con) or die ("Unable to Delete
Product");
$delproductmsg = "Deleted $name2 from $p_cat_name";
}
--ENDS HERE---
Dave Carrera
Website Designer
http://www.davecarrera.com
--
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