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 2 of 2

Thread: foreach()

  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question foreach()

    is there any other option rather than using foreach() function to retrieve the value of checkboxes that is selected???..
    because every checkbox that i selected, new sets of users are displayed.what i want is, while loop will still print USER INFO before it prints TASK..
    PHP Code:
    if (isset($_POST['cb']))
    {
            foreach (
    $_POST['cb'] as $key => $value)
            {  
    //USER INFO
                
    $result=mysql_query("SELECT * FROM user where user_id='$value'    
                             order by user_id desc;"
    ) or
                             die(
    "Can't perform query: ".mysql_query    ());
                while(
    $row=mysql_fetch_array($result))
                {
                  echo
    "<br>Firstname : ";
                  echo
    $row[firstname];
                  echo
    "&nbsp;";
                  echo
    $row[lastname];
                  echo
    "<br>Username : ";
                  echo
    $row[username];
                  echo
    "<br>";
                }
                
    //TASK
                
    $result=mysql_query("SELECT * FROM task order by task_id asc;"
                or die(
    "Can't perform query: ".mysql_query());
                while(
    $row=mysql_fetch_array($result))
                {
                  echo
    "<br>&nbsp;&nbsp;   ";
                  echo
    "<input type='checkbox'> $row[task_name]";
                  
    $r=mysql_query("SELECT sub_name FROM subtask where 
                      task_id=$row[task_id];"
    ) or 
                      die(
    "Can't perform query: ".mysql_query());
                  while(
    $row=mysql_fetch_assoc($r))
                  {
                     echo
    "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                     echo
    "<input type='checkbox'>&nbsp;$row[sub_name]";
                  } 
                }
            };

    somebody please please help me with this ....
    thanks all ...

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can you explain in a bit more detail please?


  •  

    Posting Permissions

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