Form part:
Copy codeThe Code is as follows:
<Form action = "? Action = edit_num "method =" post "name =" car <? Php $ c_rs ['id'];?> "Id =" car <? Php $ c_rs ['id'];?> ">
<Input name = "suliang [<? Php echo $ c_rs ['SP _ id'];?>] "Type =" text "id =" suliang [<? Php echo $ c_rs ['SP _ id'];?>] "Value =" <? Php echo $ c_rs ['suliang '];?> "/>
<Input type = "submit" name = "button" id = "button" value = "Update Shopping Cart"/>
</Form>
PHP Processing:
Copy codeThe Code is as follows:
<? Php
Require 'config. inc. php ';
Require 'checklogin. php ';
$ Username = $ _ SESSION ['username'];
$ Action = $ _ GET ['action'];
Switch ($ action ){
Case "edit_num ":
$ Arr = $ arr =$ _ POST ['suliang '];
Foreach ($ arr as $ key => $ value ){
$ Sqlgx = "update 'cartemp 'set suliang =' $ value' where username = '". $ username. "'and flag = 0 and sp_id = '". $ key. "'";
Mysql_query ($ sqlgx, $ conn );
Echo "<script> location. href = 'shopcat. php' </script> ";
}
Break;
Case "null ":
$ Null_ SQL = "delete from 'cartemp 'where username =' $ username' and flag = 0 ";
Mysql_query ($ null_ SQL, $ conn );
Echo "<script> location. href = 'shopcat. php' </script> ";
Break;
Case "del ":
$ Id = $ _ GET ['id'];
$ Del_ SQL = "delete from 'cartemp 'where id = $ id ";
Mysql_query ($ del_ SQL, $ conn );
Echo "<script> location. href = 'shopcat. php' </script> ";
Break;
}
?>