how do i put line number on printout

Discussion in 'PHP' started by dougvcd, Feb 1, 2008.

  1. #1
    hi
    i have this code which prints out from database but would like to have a line number
    some thing like num$
    i tried
    let num$=0
    let num$=num$+1
    but not sure how to put it into code
    here is the code i have

    //Retrieves data from MySQL
      $data = mysql_query("SELECT * FROM members WHERE region='exchange' OR region='EXCHANGE/HIRE' or region='EXCHANGE' or region='HIRE'") or die(mysql_error());
    //Puts it into an array 
    while($info = mysql_fetch_array( $data )) 
    { 
    //Outputs the image and other data
    Echo "<b>Name:</b> ".$info['name'] . "  ";
    Echo "<b>Email:</b> ".$info['email'] . " <br>";
    } 
    
    ?> 
    </p>
    <p><a href="javascript: window.print();">Print Out</a></p>
    <p><a href="index.php">Home</a> </p>
    </body>
    PHP:
    cheers
    Doug
     
    dougvcd, Feb 1, 2008 IP
  2. sharqi

    sharqi Guest

    Messages:
    105
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    //Retrieves data from MySQL
      $data = mysql_query("SELECT * FROM members WHERE region='exchange' OR region='EXCHANGE/HIRE' or region='EXCHANGE' or region='HIRE'") or die(mysql_error());
    //Puts it into an array 
    $i=1;  //line one to start
    while($info = mysql_fetch_array( $data )) 
    { 
    //Outputs the image and other data
    echo "Line Number: " . $i;
    Echo "<b>Name:</b> ".$info['name'] . "  ";
    Echo "<b>Email:</b> ".$info['email'] . " <br>";
    $i++; //add one to $i for the next loop. This is the same as doing $i = $i+1;
    } 
    
    ?> 
    </p>
    <p><a href="javascript: window.print();">Print Out</a></p>
    <p><a href="./">Home</a> </p>
    </body>
    PHP:
     
    sharqi, Feb 1, 2008 IP
  3. dougvcd

    dougvcd Peon

    Messages:
    267
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    sorry but i cant get it to work
    Doug
    ok my typing error all working
    cheers
     
    dougvcd, Feb 1, 2008 IP
  4. dougvcd

    dougvcd Peon

    Messages:
    267
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    how do you put a space between the fields not between the lines
    i tried
    Echo " "; but this did not work
    cheers
    Doug
     
    dougvcd, Feb 1, 2008 IP