Results 1 to 2 of 2

Thread: dividing data into columns

  1. #1

    Default dividing data into columns

    I have a list of data from my database that is listed via php into one column, this fits my needs for right now. How ever I will shortly this will make the web page to long. I am looking for a simple way to take what I have now and once it reaches 20 entry's to start listing it into another column, and then after 40 are listed it would create a new page.

    Thanks in advance

    This is what I have that lists everything in one column.
    PHP Code:
    include"scripts/connect.php" ;

    mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT * FROM movies WHERE type LIKE 'movie' ORDER BY title";


    <table width="80%" align="left">
    <td>Movies </td>
    while (
    $i $num) {


    <td><font face="Arial, Helvetica, sans-serif"><a href=/rules.php?title=<? echo urlencode($title); ?>><?php echo $title?></a></font></td>



  2. #2
    Join Date
    Nov 2006
    Sydney, Australia


    To add an extra column means you'd need to store the first 20 before outputting anything so that you can output entry 21 alongside entry 1 and so on.

    It would be easier if the data goes across rather than down because then you just remove the </tr><tr> after the odd numbered entries.

    Adding processing for multiple pages means that you need to pass the current position between pages and then amend your database query to use that start position as the OFFSET and get just the next 40 entries using LIMIT 40.

Posting Permissions

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