Xtremer360 Posted March 18, 2011 Share Posted March 18, 2011 I'm just trying to get suggestions on what people think would be the best way to go with this. With the bottom part of this card where it s tarts working with the foreach loop its taking what was a UL and for each of each LI's and updating a table with its new data however this way isn't going to work as this is editing a user. Because there could be 5 in the database but the new edit user has only 4 lis so I'm sure you could all see the issue here. What I'm thinking would be best is to have it DELETE the existing characterIDs that have WHERE handler_ID = $handlerID and then just do a new INSERT statement. Anyone else think this would be the best way to go about this? if (mysqli_num_rows($Qresult) == 0) { $query = "UPDATE `handlers` SET `userName` = '".$userName."', `password`='".$password."', `firstName`='".$firstName."', `lastName`='".$lastName."', `statusID`='".$statusID."', `isAdmin`='".$admin."', `defaultCharID`='".$defaultCharID."', `email`='".$email."' WHERE `ID` = '".$handlerID."'"; mysqli_query($dbc, $query); foreach ($characterIDs as $cID) { $query2 = "UPDATE `handler_characters` SET `handler_id` = '".$handlerID."', `characterID` = '".$cID."'"; mysqli_query($dbc, $query2); } $result = "good"; } Quote Link to comment Share on other sites More sharing options...
ocpaul20 Posted March 19, 2011 Share Posted March 19, 2011 When I look at this I think... do I want to spend time trying to understand what this guy needs or do I want to go to another thread and answer a question that is a general question that I can answer in 2 minutes. The problem we have is that there are so many people asking specific questions about their application or website and we have to spend time getting into the code and trying to understand it. You will probably have more luck with an answer if you extract the problem from your code and ask a general question. This is a design problem and we need to understand the application to best advise you. I realise you think you have extracted the problem, but it is specific to your use so we have to try to understand what you are trying to do first, then we can answer the question. That is taking more of our time you see. I am not being unhelpful but I am trying to show you our problem and how you can ask a question which is more likely to get a satisfactory solution for you. Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted March 20, 2011 Author Share Posted March 20, 2011 Okay let me re-explain this. Say your editing a user and the there's a UL with LIs foreach of the character's they control and when the page loads there's 4 since they currently control 4 characters. However after removing one of those LIs the user now owns 3 characters now when you take that to a table called handlerCharacters there's the fields called ID, handlerID, characterID which would have those 4 characters in each in a new row in the database with the user's ID in the handlerID field. Now that there's only 3 or even if you had added one would it be best to delete those and then re-insert the new values or can you do REPLACE or what would be the best way to go about it. Quote Link to comment 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.