SpireLink Posted September 16, 2007 Share Posted September 16, 2007 Hi all, i am working on a script which will allow me to add, list, update, and remove recordsfrom database Untile now i was able to add, but i cant delete.. the code usage ADD: base.php?crl=rank.php&do=add LIST:base.php?crl=rank.php&do=modify UPDATE:base.php?crl=rank.php&do=update&id= DELETE: base.php?crl=rank.php&do=delete&id= sorry, its rank.php not ranl.php Thanks [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/69569-solved-records-managment-with-functions/ Share on other sites More sharing options...
rarebit Posted September 16, 2007 Share Posted September 16, 2007 There's only code for add, just an empty handler for each of the other functions! Quote Link to comment https://forums.phpfreaks.com/topic/69569-solved-records-managment-with-functions/#findComment-349567 Share on other sites More sharing options...
SpireLink Posted September 16, 2007 Author Share Posted September 16, 2007 There's only code for add, just an empty handler for each of the other functions! I got it, you mean the $id it was a typo, cause i got tired of trying so i changed $id to $zaim, any how i have updated the file [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/69569-solved-records-managment-with-functions/#findComment-349570 Share on other sites More sharing options...
SpireLink Posted September 17, 2007 Author Share Posted September 17, 2007 could somebody help me pls ? Quote Link to comment https://forums.phpfreaks.com/topic/69569-solved-records-managment-with-functions/#findComment-349884 Share on other sites More sharing options...
wildteen88 Posted September 17, 2007 Share Posted September 17, 2007 rank.txt only contains two functions, add and remove. In order for list and update to work you must add those functions in. rank.txt calls either add, remove, update or list functions depending on what $_GET['do'] is set to. Quote Link to comment https://forums.phpfreaks.com/topic/69569-solved-records-managment-with-functions/#findComment-349936 Share on other sites More sharing options...
SpireLink Posted September 17, 2007 Author Share Posted September 17, 2007 rank.txt only contains two functions, add and remove. In order for list and update to work you must add those functions in. rank.txt calls either add, remove, update or list functions depending on what $_GET['do'] is set to. Wide, i know that .. The thing that the add works, but the remove is not working .. i have used a java script to tell me that the remove was done, but it doesn't ... Thanks Quote Link to comment https://forums.phpfreaks.com/topic/69569-solved-records-managment-with-functions/#findComment-349959 Share on other sites More sharing options...
wildteen88 Posted September 17, 2007 Share Posted September 17, 2007 Oh, I see. Maybe because your link is base.php?crl=rank.php&do=delete&id= and not base.php?crl=rank.php&do=remove&id= Quote Link to comment https://forums.phpfreaks.com/topic/69569-solved-records-managment-with-functions/#findComment-349962 Share on other sites More sharing options...
SpireLink Posted September 18, 2007 Author Share Posted September 18, 2007 Oh, I see. Maybe because your link is base.php?crl=rank.php&do=delete&id= and not base.php?crl=rank.php&do=remove&id= Hi, I have done this // START DELETE RANK function remove ($id) { if (isset($HTTP_GET_VARS['id'])) { $rank_id = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['id'] : addslashes($HTTP_GET_VARS['id']); } include("../includes/config.php"); $remove="DELETE FROM ranks WHERE rank_id=$rank_id"; $remove_rank=mysql_query($remove,$db); } // END DELETE RANK and changed the link to be base.php?crl=rank.php&do=remove&id=3 but it's stell not removing that record ... Quote Link to comment https://forums.phpfreaks.com/topic/69569-solved-records-managment-with-functions/#findComment-350225 Share on other sites More sharing options...
wildteen88 Posted September 18, 2007 Share Posted September 18, 2007 Why are you retrieving the id from get in your function? The id already gets passed to the function from the code at the top of your script. Change your function to: // START DELETE RANK function remove ($id) { if (is_numeric($id) { include("../includes/config.php"); $sql= "DELETE FROM ranks WHERE rank_id=$id"; if(mysql_query($sql, $db)) { echo 'Record deleted'; } else { echo 'Unable to delete record!<br />Query: ' . $sql . '<br /><br />' . mysql_error($db); } } else { echo 'id must only be a number!'; } } // END DELETE RANK Quote Link to comment https://forums.phpfreaks.com/topic/69569-solved-records-managment-with-functions/#findComment-350531 Share on other sites More sharing options...
SpireLink Posted September 20, 2007 Author Share Posted September 20, 2007 thanks, it works like a charm even i have added the function that will show ma a list with the modify/delete link so i will be able to do it.. now the thing in that i cant update the data, it show me the current data but when i change any thing in there it doesnt update the record and show me an error message [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/69569-solved-records-managment-with-functions/#findComment-351515 Share on other sites More sharing options...
SpireLink Posted September 20, 2007 Author Share Posted September 20, 2007 i have tested it with echo to show me the values, and it was not having the record ID so it wasn't updating the data, i workes around it by adding a hidden field in the form whcih will contain the record ID and pass it to the SQL query.. and it works Quote Link to comment https://forums.phpfreaks.com/topic/69569-solved-records-managment-with-functions/#findComment-351536 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.