www.webdeveloper.com
Results 1 to 7 of 7

Thread: [RESOLVED] help with script to email values up to 240 fields

  1. #1
    Join Date
    Oct 2007
    Posts
    175

    resolved [RESOLVED] help with script to email values up to 240 fields

    Issue:
    it wont display the values when emailed, I modified the script below but I think I'm doing something wrong.

    the fields consist of:

    1st row: textbox_r1_c1, textbox_r1_c2, textbox_r1_c3, textbox_r1_c4, textbox_r1_c5, textbox_r1_c6, textbox_r1_c7, textbox_r1_c8, textbox_r1_c9
    2nd row: textbox_r2_c1 through textbox_r2_c9
    3rd row: textbox_r3_c1 through textbox_r3_c9
    4th row: textbox_r4_c1 through textbox_r4_c9
    5th row: textbox_r5_c1 through textbox_r5_c9
    and so on up to 240
    240th row: textbox_r240_c1 through textbox_r240_c9

    PHP Code:
    $numrows count($_POST['textbox_r1_c1']); // number of rows ;) will always be accurate...

    for($a 0$a $numrows$a++) {
      
    $emptyrow true;
      
    $temp[] = '<tr>';
      for(
    $b 0$b 9$b++) {

           
    $temp[] = '<td align="right">' $_POST['textbox_r'.$a'_c'.$b] . '</td>';
           if(
    $_POST['textbox_r'.$a'_c'.$b] != '')
              
    $emptyrow false;
      }
      
      
    $temp[] = '</tr>';
      if(
    $emptyrow == false)
        
    $out[] = implode($temp'');
      unset(
    $temp);
    }

    $msg .= implode($out''); 
    "The one who's closer to the truth is the one still looking"
    Jodarecode "Hence" - Chaos -

  2. #2
    Join Date
    Sep 2004
    Location
    Sri Lanka
    Posts
    469
    what if text box names used as array,

    <input type="textbox_r1[]"> in all nine locations, so at form processing page,

    foreach($textbox_r1 as $r1)
    {
    .....

    }

    For your requirement sometimes multi-dimentional array names may help, but I havent used that before ..

    PHP Code:
    <input type="textbox[0][]">
    .
    .
    <
    input type="textbox[239][]"
    Last edited by GUIR; 03-15-2009 at 10:36 AM.

  3. #3
    Join Date
    Oct 2007
    Posts
    175
    I'm trying to avoid the brackets if at all possible since certain codes are dependent on no brackets.

    I found a solution but I'm back to the beginning with an old question again.

    I need all the empty rows to not show when emailed or printed and to only show non empty values in there respected columns only.

    PHP Code:
    foreach($_POST as $key => $val){
      if(
    preg_match("/textbox_r\d+\_c1/"$key)){
        
    $msg .= "<tr><td>$val</td>";
      };
      if(
    preg_match("/textbox_r\d+\_c2/"$key)){
        
    $msg .= "<td>$val</td>";
      };
      if(
    preg_match("/textbox_r\d+\_c3/"$key)){
        
    $msg .= "<td>$val</td>";
      };
      if(
    preg_match("/textbox_r\d+\_c4/"$key)){
        
    $msg .= "<td>$val</td>";
      };
      if(
    preg_match("/textbox_r\d+\_c5/"$key)){
        
    $msg .= "<td>$val</td>";
      };
      if(
    preg_match("/textbox_r\d+\_c6/"$key)){
        
    $msg .= "<td>$val</td>";
      };
      if(
    preg_match("/textbox_r\d+\_c7/"$key)){
        
    $msg .= "<td>$val</td>";
      };
      if(
    preg_match("/textbox_r\d+\_c8/"$key)){
        
    $msg .= "<td>$val</td>";
      };
      if(
    preg_match("/textbox_r\d+\_c9/"$key)){
        
    $msg .= "<td>$val</td></tr>";
      };
    }; 
    "The one who's closer to the truth is the one still looking"
    Jodarecode "Hence" - Chaos -

  4. #4
    Join Date
    Aug 2006
    Location
    Michigan
    Posts
    1,046
    You have some errors in your code

    Fixed
    PHP Code:
    $numrows count($_POST['textbox_r1_c1']); // number of rows ;) will always be accurate...

    for($a 0$a $numrows$a++) {
      
    $emptyrow true;
      
      
    $temp[] = '<tr>';
      for(
    $b 0$b 9$b++) {

           
    $temp[] = '<td align="right">' $_POST['textbox_r'.$a.'_c'.$b] . '</td>'// Error after $a no . for line concat
           
    if($_POST['textbox_r'.$a.'_c'.$b] != ''// Same error as above
              
    $emptyrow false;
      }
      
      
    $temp[] = '</tr>';
      if(
    $emptyrow == false)
        
    $out[] = implode($temp'');
      unset(
    $temp);
    }

    $msg .= implode($out''); 

  5. #5
    Join Date
    Oct 2007
    Posts
    175
    OK, fixed that [EDIT:] Thats funny I just saw that!! I'll re-step through it Thanks!

    Now it pushes the values one TD to the right leaving a blank TD in the beginning and extending the 9th TD into the 10th column, Why would this be happening? any ideas?

    PHP Code:
    $numrows count($_POST['textbox_r1_c1']);
    for(
    $a 0$a <= 240$a++) {
      
    $emptyrow true;
      
    $temp[] = '<tr>';
      for(
    $b 0$b <= 9$b++) {
           
    $temp[] = '<td align="right">' $_POST['textbox_r'.$a.'_c'.$b] . '</td>';
           if(
    $_POST['textbox_r'.$a.'_c'.$b] != '')
              
    $emptyrow false;
      }
      
    $temp[] = '</tr>';
      if(
    $emptyrow == false)
        
    $out[] = implode($temp'');
      unset(
    $temp);
    }
    $msg .= implode($out''); 
    Last edited by Jodarecode; 03-17-2009 at 10:44 AM.
    "The one who's closer to the truth is the one still looking"
    Jodarecode "Hence" - Chaos -

  6. #6
    Join Date
    Oct 2007
    Posts
    175
    I seem to of replaced numrows with 240 and added the dots and seems to be working fine except the same problem as earlier with the whole row pushed one TD to the right.

    PHP Code:
    for($a 0$a <= 240$a++) {
      
    $emptyrow true;
      
    $temp[] = '<tr>';
      for(
    $b 0$b <= 9$b++) {
           
    $temp[] = '<td align="right">' $_POST['textbox_r'.$a.'_c'.$b] . '</td>';
           if(
    $_POST['textbox_r'.$a.'_c'.$b] != '')
              
    $emptyrow false;
      }
      
    $temp[] = '</tr>';
      if(
    $emptyrow == false)
        
    $out[] = implode($temp'');
      unset(
    $temp);
    }
    $msg .= implode($out''); 
    "The one who's closer to the truth is the one still looking"
    Jodarecode "Hence" - Chaos -

  7. #7
    Join Date
    Oct 2007
    Posts
    175
    Resolved!

    needed to change
    PHP Code:
     for($b 0$b <= 9$b++) 
    to
    PHP Code:
     for($b 1$b <= 9$b++) 
    PHP Code:
    for($a 0$a <= 240$a++) {
      
    $emptyrow true;
      
    $temp[] = '<tr>';
      for(
    $b 1$b <= 9$b++) {
           
    $temp[] = '<td align="right">' $_POST['textbox_r'.$a.'_c'.$b] . '</td>';
           if(
    $_POST['textbox_r'.$a.'_c'.$b] != '')
              
    $emptyrow false;
      }
      
    $temp[] = '</tr>';
      if(
    $emptyrow == false)
        
    $out[] = implode($temp'');
      unset(
    $temp);
    }
    $msg .= implode($out''); 
    "The one who's closer to the truth is the one still looking"
    Jodarecode "Hence" - Chaos -

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles