Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2010
    Location
    Earth
    Posts
    305
    Thanks
    27
    Thanked 2 Times in 2 Posts

    stuck on an array

    I have a 2 forms that work separetly but I have them nested, from what I've read I shouldn't do this. The nested forms are working except for the format which makes the container box double in length, no matter what I do. So I am trying to do it the proper way but cannot figure out how to combine my 2nd array with the main one.

    Would appreciate some help

    This is the main form, it allows you to select messages or a message and set it to something different. Think of email but with check boxes.

    Code:
    	<form action='' method='POST' name='myForm' id='user'>
    		<div id='newMsgButtons'>
    			<input type='submit' name='unread' value='Mark Unread' class='btn' onmouseover=\"this.className='btn btnhov'\" onmouseout=\"this.className='btn'\">&nbsp;&nbsp;<img src='img/line.png' width='1' height='13'>&nbsp;
    			<input type='submit' name='read' value='Mark Read' class='btn' onmouseover=\"this.className='btn btnhov'\" onmouseout=\"this.className='btn'\">&nbsp;&nbsp;<img src='img/line.png' width='1' height='13'>&nbsp;
    			<input type='submit' name='delete' value='Delete' class='btn' onmouseover=\"this.className='btn btnhov'\" onmouseout=\"this.className='btn'\">
    		</div>
    		<div id='selectAll'>Select: <a href=\"javascript:selectToggle(true, 'myForm');\">All</a>, <a href=\"javascript:selectToggle(false, 'myForm');\">None</a></div>	";
    
    		echo"<span class='checkbox'><input type='checkbox' name='answers[]' value='$id'></span>";
    Once your selection has been made it kicks it to this code and process it (there is more code this is just one)

    PHP Code:
    $my_array $_POST['answers'];
        
    // sets message to Unread status
        
    if($_POST['unread']){
            
    $totalIDs count($my_array);
            for ( 
    $i=0$i $totalIDs$i++ ) {
                
    $sql2 mysql_query("SELECT sender FROM nudges WHERE id='$my_array[$i]'");
                while(
    $r mysql_fetch_array($sql2)) {
                    
    $sender=$r['sender'];
        
                    
    $query12 = ("UPDATE nudges SET r_status=0 WHERE id='$my_array[$i]'");
                    
    $result12 mysql_query($query12) or die(mysql_error());
                } 
    // END while
            
    // END for
        
    // END if($_POST['unread']) 

    So now I want to take the 2nd form and be able to combine with the main form

    PHP Code:
    $query7 mysql_query("SELECT * FROM blockUser WHERE blockUserID='$clientID' AND blockID='$sender'");
                
    $num_rows mysql_num_rows($query7);
                
                if (
    $num_rows >= ) {
                    echo 
    "<img src='img/delete2.png'  title='Blocked'>";
                }
                else {
                    echo 
    "
                        <input type='hidden' name='block2' value='$sender' />
                        <input type='image' value='Block' src='delete.png'  title='Block'>
                    "
    ;
                } 
    This is its processing code

    PHP Code:
    if($_POST['block2']){        
          
    //checking to see that user is in the saved, if it is removing it
            
    $result2 mysql_query("SELECT * FROM saveUser WHERE userID='$clientID' AND saveID='$block_array[$i]'");
            
    $num_rows mysql_num_rows($result2);

            
    // deleting from table
            
    if ($num_rows >= ) {
                
    $query1 "DELETE FROM saveUser WHERE userID='$clientID' AND saveID='$block_array[$i]'";
                
    $result mysql_query($query1) or die(mysql_error());
            }
            
            
    //checking to see that user is in the saved, if it is removing it
            
    $result3 mysql_query("SELECT * FROM blockUser WHERE blockUserID='$clientID' AND blockID='$block_array[$i]'");
            
    $num_rows3 mysql_num_rows($result3);    
        
            if (
    $num_rows3 == ) {
                
    // now inserting info to block the user from appearing        
                
    $query2 = ("INSERT INTO blockUser VALUES(NULL,'$clientID','$block_array[$i]')");
                
    $result2 mysql_query($query2) or die(mysql_error());
            }


    I have modified the form and the processing code for an array but cannot get anything to work.

    I've been working on this all day and finally decided that I need help, if someone can point me in the right direction.
    Last edited by harkly; 02-01-2012 at 08:45 PM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    You can't nest two forms as it'll produce an invalid markup. Think about something else.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Jun 2010
    Location
    Earth
    Posts
    305
    Thanks
    27
    Thanked 2 Times in 2 Posts
    I know which is why I am asking for help with my array

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    So now I want to take the 2nd form and be able to combine with the main form
    Sorry, but where's your second form?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    Regular Coder
    Join Date
    Jun 2010
    Location
    Earth
    Posts
    305
    Thanks
    27
    Thanked 2 Times in 2 Posts
    The 3rd code box was the second form, which I have tried to convert to work with the array.

    The 4th code box is the processing for that form.


    this is was it used to be

    PHP Code:
    $query7 mysql_query("SELECT * FROM blockUser WHERE blockUserID='$clientID' AND blockID='$sender'"); 
                
    $num_rows mysql_num_rows($query7); 
                 
                if (
    $num_rows >= ) { 
                    echo 
    "<img src='img/delete2.png'  title='Blocked'>"
                } 
                else { 
                    echo 

                        <form ......>
                         <input type='hidden' name='block2' value='$sender' /> 
                         <input type='image' value='Block' src='delete.png' title='Block'> 
                        </form>


                    "

                } 

    My guess is that I need to take
    Code:
    name='block2' value='$sender'
    and turn that into an array
    Code:
    name='block2[]' value='$sender'
    When I do that I just get the very last one to 'process'
    ie.
    if I have 3 names
    John
    Mike
    Sue

    and I select John, Sue is the one that is processed
    Last edited by harkly; 02-01-2012 at 03:01 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •