DJTim666 Posted December 10, 2007 Share Posted December 10, 2007 I am trying to allow my users to type the amount of things they would like to remove from a gallery. So lets say they have 40 of the same thing in the gallery and they want to remove 23. {GALLERY ITEM} | {QUANTITY} | {AMOUNT TO REMOVE} I've tried several different things with all of them failing. Anyone have an idea? -- DJ Link to comment https://forums.phpfreaks.com/topic/80947-solved-removing-things/ Share on other sites More sharing options...
kratsg Posted December 10, 2007 Share Posted December 10, 2007 How are these items stored in the gallery? Is this a database with each item being a separate row? And is your question pertaining to coding the form, or coding the script to handle the form? Link to comment https://forums.phpfreaks.com/topic/80947-solved-removing-things/#findComment-410646 Share on other sites More sharing options...
DJTim666 Posted December 10, 2007 Author Share Posted December 10, 2007 Items are stored in a database and each item is a seperate row. They are stored by location. For galleries the location of the items is 9. And my question is how am I supposed to handle the form when submitted. Link to comment https://forums.phpfreaks.com/topic/80947-solved-removing-things/#findComment-410649 Share on other sites More sharing options...
kratsg Posted December 10, 2007 Share Posted December 10, 2007 I believe the LIMIT will help you here $gallery_item = mysql_real_escape_string($_POST['item']); $amt_to_remove = mysql_real_escape_string($_POST['amount']); mysql_query("DELETE FROM `table` WHERE `some_item` = $gallery_item LIMIT $amt_to_remove") or die(mysql_error()); See if that works ;-) Link to comment https://forums.phpfreaks.com/topic/80947-solved-removing-things/#findComment-410654 Share on other sites More sharing options...
DJTim666 Posted December 10, 2007 Author Share Posted December 10, 2007 Won't work because I am updating locations not deleting items. Link to comment https://forums.phpfreaks.com/topic/80947-solved-removing-things/#findComment-410655 Share on other sites More sharing options...
kratsg Posted December 10, 2007 Share Posted December 10, 2007 Then change from mysql delete, to mysql update mysql_query("UPDATE `table` SET `location` = '#' WHERE `some_item` = $gallery_item LIMIT $amt_to_remove") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/80947-solved-removing-things/#findComment-410657 Share on other sites More sharing options...
DJTim666 Posted December 10, 2007 Author Share Posted December 10, 2007 That might work. Trying now. Link to comment https://forums.phpfreaks.com/topic/80947-solved-removing-things/#findComment-410660 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.