Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-21-2009, 01:45 AM   PM User | #1
Daniellez
Regular Coder

 
Join Date: Jan 2009
Posts: 153
Thanks: 47
Thanked 0 Times in 0 Posts
Daniellez is on a distinguished road
Help adding another loop to existing for loop

The $lvNum variable works for the first table row but continues to display f4 in subsequent rows. I assume it's not incrementing because I'm not integrating it into the existing for loop properly (still a novice obviously :) Can someone help and maybe explain briefly how it works?

PHP Code:
<?php
for($i=2$i<=$numberofrecipients$i++) {
    
$value = isset($_POST['to'][$i]) ? $_POST['to'][$i] : '';
    
$lvNum 3;
    {
?>
<tr>
    <td class="formtext3"><?php echo $i ?>.</td>
    <td><input id="f<?=++$lvNum?>" type="text" name="to[<?php echo $i ?>]" value="<?php echo $value ?>">
    <script type="text/javascript">
        var f<?=$lvNum?> = new LiveValidation('f<?=$lvNum?>');
        f<?=$lvNum?>.add(Validate.Email );
    </script>
    </td>
</tr>
<?
    
}
}
?>

Disregard, this works:

PHP Code:
<?php
    
for($i=2$i<=$numberofrecipients$i++) {
        
$value = isset($_POST['to'][$i]) ? $_POST['to'][$i] : '';
        
$lvNum $i 2;
        {
    
?>
    <tr>
        <td class="formtext3"><?php echo $i ?>.</td>
        <td><input id="f<?php echo $lvNum ?>" type="text" name="to[<?php echo $i ?>]" value="<?php echo $value ?>">
        <script type="text/javascript">
            var f<?php echo $lvNum ?> = new LiveValidation('f<?php echo $lvNum ?>');
            f<?php echo $lvNum ?>.add(Validate.Email );
        </script>
        </td>
    </tr>
    <?
        
}
    }
    
?>

Last edited by Daniellez; 03-21-2009 at 04:19 AM..
Daniellez is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:47 AM.


Advertisement
Log in to turn off these ads.