Jump to content

Guys need some urgent help plzzz


doug007

Recommended Posts

mu code below inserts the tag_name for checkbox.  this works fine on firefox, but does not work on IE unless you submit twice?  Any help much appricited.

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>";



        }

    }

Link to comment
Share on other sites

Please format your code so it is easier to read.

sorry really stressed with this code.

 

here you go:

 

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>";

        }

    }

 

basically the storry is that every since i inserted the php inside the html tags this has stopped working.  here is the bit that i am talking about:

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 >";

 

Link to comment
Share on other sites

anybody please.  let rephrase this input field is not posted on IE unless you submit twice:

echo"<input type=\"hidden\" name=\"tag_name[$i]\" value='".$row['tag_name']."'></input>";

 

and it is doing this because i placed some php code inside the html tags:

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 ></input>";
				}
			}

echo"<input type=\"hidden\" name=\"tag_name[$i]\" value='".$row['tag_name']."'></input>";

Link to comment
Share on other sites

Just briefly looked this over, but

<?php echo"<input type=\"hidden\" name=\"tag_name[$i]\" value='".$row['tag_name']."'></input>"; ?>

 

Value has single quotes around the double quotes. Shouldnt it be:

<?php echo"<input type=\"hidden\" name=\"tag_name[$i]\" value=\"".$row['tag_name']."\"></input>"; ?>

Link to comment
Share on other sites

Just briefly looked this over, but

<?php echo"<input type=\"hidden\" name=\"tag_name[$i]\" value='".$row['tag_name']."'></input>"; ?>

 

Value has single quotes around the double quotes. Shouldnt it be:

<?php echo"<input type=\"hidden\" name=\"tag_name[$i]\" value=\"".$row['tag_name']."\"></input>"; ?>

 

I just tried that, but no joy, i am still having to submit twice on IE for tag_name to insert.  so desperate to get this working.  Is there a way on one click to submit the form twice?

Link to comment
Share on other sites

damn...hmm IE is usually picky like that so that's just what came to mind. Another thing is the "c_options[$i]" field also has the same syntax on it as the hidden field. Also try changing the input tags to:

 

<?php echo"<input type=\"hidden\" name=\"tag_name[$i]\" value=\"".$row['tag_name']."\" />"; ?>

 

Even if it doesnt do anything, at least it's more valid xhtml ^_^

 

When you say submit the form twice, do you mean double click submit, or hit submit, wait for a reload of the page and then click submit again?

Link to comment
Share on other sites

damn...hmm IE is usually picky like that so that's just what came to mind. Another thing is the "c_options[$i]" field also has the same syntax on it as the hidden field. Also try changing the input tags to:

 

<?php echo"<input type=\"hidden\" name=\"tag_name[$i]\" value=\"".$row['tag_name']."\" />"; ?>

 

Even if it doesnt do anything, at least it's more valid xhtml ^_^

 

When you say submit the form twice, do you mean double click submit, or hit submit, wait for a reload of the page and then click submit again?

 

I already changed that.  it still does not work.  One click and submit twice I dont mind how it does it, at least this problem is then solved....any ideas.

 

cheers

Link to comment
Share on other sites

Oops, I meant before the idea of making a form submit twice when clicked once(which I don't know if it's possible. I don't think it is, I tried to do something similar but it had AJAX and other crap involved, it was a mess haha). So in IE6 what did you have to do to make it work. Double click submit or single click then wait for a reload then click again?

Link to comment
Share on other sites

Oops, I meant before the idea of making a form submit twice when clicked once(which I don't know if it's possible. I don't think it is, I tried to do something similar but it had AJAX and other crap involved, it was a mess haha). So in IE6 what did you have to do to make it work. Double click submit or single click then wait for a reload then click again?

 

I have not tested this in IE6, it works on Firefox....damnnn i just dont see why its not submiting the tag_name of one click ?

Link to comment
Share on other sites

Can you try building a simpler test case where the problem still happens?

 

Also note that as long as you pair up the quotes correctly IE/FF/CH/SA don't care if it's single or double quotes.  I often use

 

echo "<input type='test' name='username' value='blahblahblah'>";

 

because it saves me from having to put slashes everywhere.

Link to comment
Share on other sites

I did notice one thing which I wouldn't think would be the problem (it would either work consistently or fail consistently), but you never know

echo"<input type=\"hidden\" name=\"tag_name[$i]\" value='".$row['tag_name']."'></input>";

 

Input tags do not have an opening and closing tag, just a single tag with a space and slash at the end for proper HTML:

echo"<input type=\"hidden\" name=\"tag_name[$i]\" value='".$row['tag_name']."' />";

 

here are some other observations:

 

For the INSERT to occur the field 'set_options' must also be posted and the field 'c_options' must be present and not equal to "". Looking at the rest of the code, I would assume that is the case - but are you initiating the POST from this page or is there another page that also POSTs to this page which may not have those fields on it?

 

'set_options' is created as a hard-coded hidden field, so shouldn't be any problems there. But, 'c_options' is dynamically created. Are all those options present on the first load of the page?

 

I would try to offer more help but your code is really hard to follow.

 

By the way, this is an odd way to do this test

if(!$_POST['c_options']=="")

 

I would suggest this

if($_POST['c_options']!=="")

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.