Forum Moderators: coopster
//update.php
<input type="checkbox" value="East Bay" name="region[]" <?php if (preg_match("/East Bay/", "$region")) { echo "checked"; } else { echo ""; }?>>East Bay
<input type="checkbox" value="North Bay" name="region[]" <?php if (preg_match("/North Bay/", "$region")) { echo "checked"; } else { echo ""; }?>>North Bay <br>
<input type="checkbox" value="South Bay" name="region[]" <?php if (preg_match("/South Bay/", "$region")) { echo "checked"; } else { echo ""; }?>>South Bay
<input type="checkbox" value="Peninsula" name="region[]" <?php if (preg_match("/Peninsula/", "$region")) { echo "checked"; } else { echo ""; }?>>Peninsula <br>
<input type="checkbox" value="Bay Area" name="region[]" <?php if (preg_match("/Bay Area/", "$region")) { echo "checked"; } else { echo ""; }?>>Bay Area
<input type="checkbox" value="San Francisco" name="region[]" <?php if (preg_match("/San Francisco/", "$region")) { echo "checked"; } else { echo ""; }?>>San Francisco <br>
//updated.php
include("dbinfo.inc.php");
mysql_connect('localhost',$username,$password);$id=$_POST["id"];
$sregion = $_POST['region'];
$query="UPDATE intern_db SET region='$sregion' WHERE id='$id'";
@mysql_select_db($database) or die( "Unable to select database");
mysql_query($query);
echo "Record Updated";
mysql_close();
Any ideas? Thank you in advance.
BTW, is there a more efficient way to search for a string in a field than using preg_match?
//updated.php
include("dbinfo.inc.php");
mysql_connect('localhost',$username,$password);
$id=$_POST["id"];
if (isset($_POST['region'])) {
foreach ($_POST['region'] as $key => $value) {
$ints .= "$value, ";
}
$ints = substr($ints, 0, -2); //removes leading comma and space
}else {
echo 'You forgot to enter a region.';
}
$sregion = $ints;
$query="UPDATE intern_db SET region='$sregion' WHERE id='$id'";
@mysql_select_db($database) or die( "Unable to select database");
mysql_query($query);
echo "Record Updated";
mysql_close();
Thank you again... :o)
<input value="Bay Area" name="region[]" type="checkbox" <?php if (preg_match("/Bay Area/", "$region")) { echo "checked"; } else { echo ""; }?> >Bay Area
$valuesSets = "";
for ($i=0; $i < count($asstcoachid); $i++) {
$valuesSets.="(".GetSQLValueString($teamid[$i], "int").",".GetSQLValueString($asstcoachid[$i], "string").",".GetSQLValueString($eventid[$i], "int")."),";
}
$valuesSets=substr($valuesSets,0,-1); // to remove last comma$insertSQL = sprintf("INSERT INTO TeamAsstCoaches (teamid, asstcoachid, eventid) VALUES %s",
$valuesSets);mysql_select_db($database_usatss, $usatss);
if ($valuesSets <> "") {
// echo $insertSQL;
$Result1 = mysql_query($insertSQL, $usatss) or die(mysql_error());
}
Hope this helps someone down the road.