Please help php NOOB, i am stuck!

Discussion in 'PHP' started by 2new2, Nov 10, 2009.

  1. #1
    Hello

    I am a complete noob to php and code, I have a simple project but I just can't seem to find a solution.

    this is the code I have so far... I just need each line to stop at a count of 25 with a break and then continue up to 500.

    <?php

    $date1 = date('l F j, Y');
    $date2 = date('d/m/Y');
    $date3 = date('d/m/Y H:i:s');
    echo"
    Date 1: $date1<br />
    Date 2: $date2<br />
    Date 3: $date3<br />
    <p>&nbsp;</p>
    ";

    for($i = 1; $i <= 500; $i++)
    {
    echo"$i ";


    }

    ?>

    I would really appreciate your help, I am sure if I can see it work it will start to make sense ( I hope!).
     
    2new2, Nov 10, 2009 IP
  2. nomzz

    nomzz Well-Known Member

    Messages:
    475
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    110
    #2
    It's not making sense, can you please explain bit more where you want break ? or you want line break or you just want to break loop ?
     
    nomzz, Nov 10, 2009 IP
  3. 2new2

    2new2 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    sorry, I am not sure how to explain these things yet,

    I need a line break after every 25

    1 2 3 ........ 25
    26 27 28 .......50

    does that make sense?
     
    2new2, Nov 10, 2009 IP
  4. n3r0x

    n3r0x Well-Known Member

    Messages:
    257
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    120
    #4
    <?php
    
    $date1 = date('l F j, Y');
    $date2 = date('d/m/Y');
    $date3 = date('d/m/Y H:i:s');
    echo"
    	Date 1: $date1<br />
    	Date 2: $date2<br />
    	Date 3: $date3<br />
    	<p>&nbsp;</p>
    	";
    
    for($i = 1; $i <= 500; $i++) 
    {
    
    	echo"$i ";
      if($i%25 == 0) {
          echo "<br />";
      }
                             
    }         
    
    ?>
    PHP:

    just added

    if($i%25 == 0) {
    echo "<br />";
    }


    what this does is divide $i with 25 and take what´s left over and compares it to 0..

    In other words when $i / 25 breaks into even pieces like 1, 2, 3,4,5,6,7,8 and so on it returns 0
     
    n3r0x, Nov 10, 2009 IP