dereksheahan
asked on
Problem displaying check-box value
Hi all,
Can't seem to get the update wizard to display the correct values of a check-box. I have the check-boxs defined as Enum (Y,N) in MYSQL and in the Update Wiz I selected the display as check-box submit as check-box Y.N. I've tryed numerous values for the "equal to" field (i.e. Y,N,True) but can't get it working. Any suggestions as to what I might be doing wrong?
Thanks,
D
<?php require_once('../Connectio ns/GSM_mob ile.php'); ?>
<?php
function GetSQLValueString($theValu e, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STR ING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUE RY_STRING' ]);
}
if ((isset($_POST["MM_update" ])) && ($_POST["MM_update"] == "form2")) {
$updateSQL = sprintf("UPDATE feedback_table SET feed_name=%s, feed_feedback_text=%s, `date`=%s, online=%s, feed_checked=%s WHERE feed_feedback_id=%s",
GetSQLValueString($_POST[' feed_name' ], "text"),
GetSQLValueString($_POST[' feed_feedb ack_text'] , "text"),
GetSQLValueString($_POST[' date'], "date"),
GetSQLValueString(isset($_ POST['onli ne']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_ POST['feed _checked'] ) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST[' feed_feedb ack_id'], "int"));
mysql_select_db($database_ GSM_mobile , $GSM_mobile);
$Result1 = mysql_query($updateSQL, $GSM_mobile) or die(mysql_error());
$updateGoTo = "adminhome.php";
if (isset($_SERVER['QUERY_STR ING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_rsFeedback = "-1";
if (isset($_GET['feed_var'])) {
$colname_rsFeedback = (get_magic_quotes_gpc()) ? $_GET['feed_var'] : addslashes($_GET['feed_var ']);
}
mysql_select_db($database_ GSM_mobile , $GSM_mobile);
$query_rsFeedback = sprintf("SELECT feed_name, feed_feedback_text, `date`, online, feedback_table.feed_feedba ck_id, feedback_table.feed_checke d FROM feedback_table WHERE feedback_table.feed_feedba ck_id = %s ORDER BY `date` ASC", $colname_rsFeedback);
$rsFeedback = mysql_query($query_rsFeedb ack, $GSM_mobile) or die(mysql_error());
$row_rsFeedback = mysql_fetch_assoc($rsFeedb ack);
$totalRows_rsFeedback = mysql_num_rows($rsFeedback );
?><!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>
<form id="form1" name="form1" method="post" action="">
</form>
<form method="post" name="form2" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Feed_name:</ td>
<td><input type="text" name="feed_name" value="<?php echo $row_rsFeedback['feed_name ']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right" valign="top">Feed_feedback _text:</td >
<td><textarea name="feed_feedback_text" cols="50" rows="5"><?php echo $row_rsFeedback['feed_feed back_text' ]; ?></textarea>
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Date:</td>
<td><input type="text" name="date" value="<?php echo $row_rsFeedback['date']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Online:</td>
<td><input type="checkbox" name="online" value="" <?php if (!(strcmp($row_rsFeedback[ 'online'], ""))) {echo "@@checked@@";} ?>></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Feed_checked :</td>
<td><input type="checkbox" name="feed_checked" value="" <?php if (!(strcmp($row_rsFeedback[ 'feed_chec ked'],"")) ) {echo "@@checked@@";} ?>></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Update record"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form2">
<input type="hidden" name="feed_feedback_id" value="<?php echo $row_rsFeedback['feed_feed back_id']; ?>">
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($rsFeedb ack);
?>
Can't seem to get the update wizard to display the correct values of a check-box. I have the check-boxs defined as Enum (Y,N) in MYSQL and in the Update Wiz I selected the display as check-box submit as check-box Y.N. I've tryed numerous values for the "equal to" field (i.e. Y,N,True) but can't get it working. Any suggestions as to what I might be doing wrong?
Thanks,
D
<?php require_once('../Connectio
<?php
function GetSQLValueString($theValu
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STR
$editFormAction .= "?" . htmlentities($_SERVER['QUE
}
if ((isset($_POST["MM_update"
$updateSQL = sprintf("UPDATE feedback_table SET feed_name=%s, feed_feedback_text=%s, `date`=%s, online=%s, feed_checked=%s WHERE feed_feedback_id=%s",
GetSQLValueString($_POST['
GetSQLValueString($_POST['
GetSQLValueString($_POST['
GetSQLValueString(isset($_
GetSQLValueString(isset($_
GetSQLValueString($_POST['
mysql_select_db($database_
$Result1 = mysql_query($updateSQL, $GSM_mobile) or die(mysql_error());
$updateGoTo = "adminhome.php";
if (isset($_SERVER['QUERY_STR
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_rsFeedback = "-1";
if (isset($_GET['feed_var']))
$colname_rsFeedback = (get_magic_quotes_gpc()) ? $_GET['feed_var'] : addslashes($_GET['feed_var
}
mysql_select_db($database_
$query_rsFeedback = sprintf("SELECT feed_name, feed_feedback_text, `date`, online, feedback_table.feed_feedba
$rsFeedback = mysql_query($query_rsFeedb
$row_rsFeedback = mysql_fetch_assoc($rsFeedb
$totalRows_rsFeedback = mysql_num_rows($rsFeedback
?><!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>
<form id="form1" name="form1" method="post" action="">
</form>
<form method="post" name="form2" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Feed_name:</
<td><input type="text" name="feed_name" value="<?php echo $row_rsFeedback['feed_name
</tr>
<tr valign="baseline">
<td nowrap align="right" valign="top">Feed_feedback
<td><textarea name="feed_feedback_text" cols="50" rows="5"><?php echo $row_rsFeedback['feed_feed
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Date:</td>
<td><input type="text" name="date" value="<?php echo $row_rsFeedback['date']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Online:</td>
<td><input type="checkbox" name="online" value="" <?php if (!(strcmp($row_rsFeedback[
</tr>
<tr valign="baseline">
<td nowrap align="right">Feed_checked
<td><input type="checkbox" name="feed_checked" value="" <?php if (!(strcmp($row_rsFeedback[
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Update record"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form2">
<input type="hidden" name="feed_feedback_id" value="<?php echo $row_rsFeedback['feed_feed
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($rsFeedb
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Got it working! Was the same problem as in the last question! Had to set value equal to 'Y' instead of Y. Great Stuff!
Ah-ha...
ASKER
Yup, easy when you know how I guess. Just one of those things :)
ASKER
not sure I understand. Set what exactly in the Wizard to Text?