troubleshooting Question

Multiple Checkbox Form Help Needed

Avatar of jroe6352
jroe6352 asked on
PHPMySQL Server
25 Comments1 Solution312 ViewsLast Modified:
I need to allow users to use a checkbox to  make a change to multiple items in a mysql database - I'm a beginner at this and haven't found a good way to do this online.  I'm on a tight deadline and need to get this done.
<?PHP
require_once('../Connections/localhost.php');
mysql_select_db($database_localhost, $localhost);
//List Variables from Login Confirm Submission
$amerinetid = $_POST["amerinetid"];
$facilityname = $_POST["facilityname"];
$facilityaddress = $_POST["facilityaddress"];
$facilitycity = $_POST["facilitycity"];
$facilitystate = $_POST["facilitystate"];
$facilityzip = $_POST["facilityzip"];
$facilityphone = $_POST["facilityphone"];
/*Find any existing Media requests for this ID*/
$existingmediarequestquery = "SELECT inservicemedia.title, mediatransactions.mediatransaction_id, mediatransactions.firstdayneeded, mediatransactions.lastdayneeded FROM mediatransactions left join inservicemedia on inservicemedia.inservicemedia_id = mediatransactions.inservicemedia_id where mediatransactions.amerinetid = '$amerinetid'";
$existingmediarequestresult = mysql_query($existingmediarequestquery) or die(mysql_error());
$existingmediarequesttotal = mysql_num_rows($existingmediarequestresult);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?PHP
	if(isset($_POST["confirm"]) && trim($_POST["confirm"])!=='') {
			//Check for Existing Media Reservations for this ID 
				if(0 == $existingmediarequesttotal) {
					echo "No Requests found for this Amerinet ID<br>" .
						 "<form action='reservechange.php' method='post'>" .				
						 "<input type='hidden' name='mediatitle' value='null'/>" .
						 "<input type='hidden' name='mediafirstday' value='null'/>" .
						 "<input type='hidden' name='medialastday' value='null'/>" .
						 "<input type='hidden' name='amerinetid' value='$amerinetid'/>" .
						 "<input type='submit' name='requestnew' value='Request New'/></form>";
					}
			//Show User the Information found in the database and Confirm Submission	
				else {
		 			echo "<form action='reservechange.php' method='post'>";
					while ($existingmedianamerequestrow = mysql_fetch_array($existingmediarequestresult, MYSQL_ASSOC))
					{
					echo "<input type='checkbox' name='mediacheckbox' value='{$existingmedianamerequestrow['mediatransaction_id']}' unchecked><input type='hidden' name='mediatitle' value='{$existingmedianamerequestrow['title']}'/>{$existingmedianamerequestrow['title']} reserved from <input type='hidden' name='mediafirstday' value='{$existingmedianamerequestrow['firstdayneeded']}'/>{$existingmedianamerequestrow['firstdayneeded']} until <input type='hidden' name='medialastday' value='{$existingmedianamerequestrow['lastdayneeded']}'/>{$existingmedianamerequestrow['lastdayneeded']}<input type='hidden' name='amerinetid' value='$amerinetid'><br>";
					}
					echo "<input type='hidden' name='amerinetid' value='$amerinetid'/>" .
			      		 "<input type='submit' name='cancelselected' value='Cancel Selected'/> <input type='submit' name='requestnew' value='Request New'/></form>";
		 }
	} else {
	//Redirect to the Original Form if this page is accessed directly
	echo '<META HTTP-EQUIV="Refresh" Content="0; URL=../index.php">';
	exit;
		 }
?>
</body>
</html>
ASKER CERTIFIED SOLUTION
icarey

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 25 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 25 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros