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
  1. #1
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP Coding, Add Rows to HTML Table based on $Difference variable

    Hello,

    Working a project where I'm generating a participant roster for an event registration system. The roster shows the name of the person and a line in the column to the right for them to sign in. The system currently counts how many people are registered, and compares that to the number of seats. This is the $Difference variable. This works. What I want to do, is have the system auto add table rows with lines for write-ins. The number of rows with lines should be the same number of rows as the $Difference variable. So, if the $Difference for one event was 4, the system would add 4 rows. If it was 2, it would add 2 rows.

    How do I code this to make it work? Should be fairly easy, but I'm not getting it.

    Thanks.

    Here's my code:

    <tr>
    <td>_____________________________________</td>
    <td>&nbsp;</td>
    <td>_______________________________</td>
    </tr>

    <?php $Difference = $row_Events['maxseats'] - $row_Events['count_jid_1'];
    for ($i=0; $i < $Difference; $i++);
    $txt = "<tr>
    <td>_____________________________________</td>
    <td>&nbsp;</td>
    <td>_______________________________</td>
    ".$i.\"</tr>";
    echo ($txt);
    ?>
    </table>

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,395
    Thanks
    8
    Thanked 1,078 Times in 1,069 Posts
    PHP Code:
    <tr>
    <td>_____________________________________</td>
    <td>&nbsp;</td>
    <td>_______________________________</td>
    </tr>

    <?php $Difference $row_Events['maxseats'] - $row_Events['count_jid_1'];
    for (
    $i=0$i $Difference$i++){
    echo
    "
    <tr>
    <td>$i) </td>
    <td>_____________________________________</td>
    <td>&nbsp;</td>
    <td>_______________________________</td>
    </tr>
    "
    ;
    }
    ?> 
    </table>


  •  

    Posting Permissions

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