NiallFH Posted August 22, 2013 Share Posted August 22, 2013 What I'm trying to do seems very basic, but having not done it before I think I've become quite lost along the way. I have a record that has a list of goals, each has its own ID and also a number next to it which is the minute the goal is scored. I have written an html form which posts information the code detailed below. Here is the only input box from my form: <input type=\"hidden\" name=\"goal_id\" value=\"$gsdata[id]\"> <input type=\"text\" name=\"minute\" size=\"2\" value=\"$gsdata[minute]\"> It is displayed using a mysql_fetch_array to display a list of all goals associated to one match, so naturally there could, 2, 3, 4, or any number of records displayed as input boxes shown above. When I click the Submit button, it posts to the page shown below: $goalid = $_POST['goal_id']; foreach($_POST['minute'] as $goaltime) { mysql_query(" UPDATE pro_goals SET GoalMinute = '$goaltime' WHERE GoalID = '$goalid' ",$connection); } Can anyone offer any help? Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted August 22, 2013 Share Posted August 22, 2013 you will want to use a CASE on the insert, Barand should be able to knock you up something elegant if he sees the post, but have a look here in the interim : http://stuporglue.org/update-multiple-rows-at-once-with-different-values-in-mysql/ Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted August 22, 2013 Share Posted August 22, 2013 @NiallFH, since you started a new thread after this, one using array names in your form, so that you would even have arrays in the form processing code, this thread is no longer active. just because your code for an issue evolves, don't start new threads for the same problem, continue in the same thread, or at least have the consideration to go back to earlier threads and post in them that you no longer need help with the stated issue. 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.