Jump to content

MySQL Update Form help


leslie.g

Recommended Posts

Hi

I currently have this form to update the names of each session in the database.

However how do I go about updating more than one value. I also want to update the 'order' swell as the name so the order in which they're displayed is updated

 

I want to have another text field next to it for the order which will just be a number but i can't figure out how to update both in the foreach() function

 

<?php

						if($_POST['update_sessions']){
						foreach($_POST as $sessionid => $sessionname){
						mysql_query("UPDATE `sessions` SET `name`='".mysql_real_escape_string($sessionname)."' WHERE `id`='".mysql_real_escape_string($sessionid)."'");
						}
						echo("Done!");
						}

						?>
						<form method="post">
						<?php


							$getsessions = mysql_query("SELECT * FROM `sessions` ORDER BY `order`");
							while($sessions = mysql_fetch_array($getsessions)){
							echo("<input type='text' name='".$sessions['id']."' value='".$sessions['name']."'><br />\n");
							}
						?>
						<input type="submit" value="Update" name="update_sessions" />
						</form>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.