Is all of this code on one page or do you have the select part on a form on 
one page and the delete on another page?  
If this is all on one page, then it would only delete the last record because 
that was the last value of $id2 after the loop to fill the drop down.  
In order to select a certain record to delete, you will need to select the 
item from the drop down list and then submit it to another page to do the 
delete.  

HTH

Maureen Biorn


Dave Carrera <[EMAIL PROTECTED]> said:

> 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.
> 
> Errrrrr 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 .="<option name="delprod"
> value="$id2">$name2</option>";
> }
> 
> 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

Reply via email to