www.webdeveloper.com
Results 1 to 4 of 4

Thread: Page Break, Table and MySQL

  1. #1
    Join Date
    Mar 2003
    Posts
    48

    Question Page Break, Table and MySQL

    I am retreaving my data from the MySQL database and display it inside HTML table. What I need to do is display every sixth row of the table on the new page (when user prints it). I know that it is possible with CSS if I do something like this: <tr style=\"page-break-after: always;\"> My problem is how can I make my code to insert this line (<tr style=\"page-break-after: always;\">) every sixth row? I tried to do the following but it doesn't really work correctly. Can anybody help?

    Code:
    . . .
    
    $num_results = mysql_num_rows($result);
    
    for ($i=0; $i <$num_results; $i++)  {
    
    if($i%6==5){
    
    echo"<tr style=\"page-break-after: always;\">"; }
    
    else {
    
    echo" <tr>"; }
    
    . . .

  2. #2
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    What isn't working?

    PHP Code:
    <?PHP
    $num_results 
    24;

    for (
    $i=0$i <$num_results$i++)  {
        if(
    $i%6==5){
            echo
    "break here<br>";
        }
        else {
            echo
    "Row<br>";
        }
    }
    ?>
    Will give me:

    Row
    Row
    Row
    Row
    Row
    break here
    Row
    Row
    Row
    Row
    Row
    break here
    Row
    Row
    Row
    Row
    Row
    break here
    Row
    Row
    Row
    Row
    Row
    break here

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  3. #3
    Join Date
    Nov 2006
    Posts
    1
    plz i want it 2

  4. #4
    Join Date
    Sep 2007
    Posts
    4
    Hi.. I was needing some help also.. The above is exactly what i need, and i can get the above code working but, my problem is it when it gets data from the data base it just keeps pulling the same row of data, I dont know how to make it move to the next row of data until all rows are displayed.. any help please.. this is what i have...

    <?php
    include("conf.php");
    $connection = mysql_connect($server, $user, $pass);
    mysql_select_db($db) or die ("Unable to select database!");
    $query = "SELECT * FROM users WHERE (status='Active')";
    $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
    $row = mysql_fetch_row($result);

    $num_results = 19;
    for ($i=0; $i <$num_results; $i++) {
    if($i%5==4){
    echo "next<br>";
    }
    else {
    echo "User:$row[3]>";
    }
    }

    mysql_free_result($result);
    mysql_close($connection);

    im sure its easy for someone that knows what their doing, im just know trying to learn php...

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