
Originally Posted by
crmalibu
if condition is false, set $checked to empty string.
i have this now resolved, but the problem now is that my insert statement does not insert the tag_name when on IE unless i submit it twice, but it works on firefox.
any ideas
PHP Code:
function do_checkboxes($userid){
global $profile_info, $setting, $smarty_object, $user_info;;
if(isset($_POST['set_options'])){
if(!$_POST['c_options']==""){
foreach($_POST['c_options'] as $key=>$value) {
$tag_name=mysql_real_escape_string($_POST['tag_name'][$key]);
$id=mysql_real_escape_string($value);
$delete = "DELETE FROM tags_options where user_id = '".$user_info[user_id]."' and tag_id <> '".$id."'";
$deleteSQL = mysql_query($delete) or die(mysql_error());
//echo $deleteSQL.'<br />';
}
foreach($_POST['c_options'] as $key=>$value) {
$tag_name=mysql_real_escape_string($_POST['tag_name'][$key]);
$id=mysql_real_escape_string($value);
$oaction = "INSERT INTO tags_options (tag_id, tag_name, user_id)
VALUES('$id', '".$tag_name."', '".$user_info[user_id]."')";
// echo $oaction.'<br />';
$optionsSQL = mysql_query($oaction) or die(mysql_error());
}
if($optionsSQL){
echo '<font color=red>Your options have been saved</font>';
}
}
}
$query ="SELECT
tag_desc_id,
tag_name,
parent_id
FROM
tags_description
ORDER BY tag_name ASC";
$result = mysql_query($query);
if (!$result){
echo mysql_error();
}
elseif(mysql_num_rows($result)<=0){
//echo "No entries";
}else{
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"10\">";
echo "<form method=post>";
$i=0;
while ($row = mysql_fetch_array($result)) {
$i++;
$incr = ($incr == 3) ? 1 : $incr + 1;
if($incr == 1) echo "<tr>";
echo "<td class=\"formcheckbox2\">";
echo"<input name=\"c_options[$i]\" style=\"border-style: solid; border:0px solid; border-color: #FFFFFF\" type=\"checkbox\" border=\"0\" value='".$row['tag_desc_id']."'";
$query2 ="SELECT
tag_options_id,
tag_id,
tag_name,
user_id
FROM
tags_options";
$result2 = mysql_query($query2);
if (!$result){
echo mysql_error();
}
while ($row2 = mysql_fetch_array($result2)) {
if($row2['tag_id'] == $row['tag_desc_id'] && $row2['user_id'] == $user_info[user_id]){
//global $checked;
$checked = 'checked';
echo " $checked >";
}
}
echo"<input type=\"hidden\" name=\"tag_name[$i]\" value='".$row['tag_name']."'></input>";
echo $row['tag_name'];
echo "</td>";
if($incr == 3) echo "</tr>";
}
echo "<tr>";
echo "<td>
<input type=\"hidden\" name=\"set_options\" value=\"set_options\">
<input name=\"GO\" type=\"submit\" id=\"GO\" value=\"Save Changes\" class=\"button\">";
echo"</td>";
echo "</tr>";
echo "</form>";
echo "</table>";
}
}/*
Bookmarks