SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need Help in mysql result in multiple cells

    Hello

    I have a database of some institutes, with their name and addresses. I want to list the NAMES column wise in HTML table. The HTML table will have 3 columns.

    So if the mysql query gives 300 records, it will show the records like every column will have some data, so the column 1 will have records from 1 to 100, column 2 will have records from 101 to 200, and column 3 will have records from 201-300.

    here is the current code, but its not working properly:

    PHP Code:
    $qry $con->select_query("institutes","distinct Names","order by Names");
        
    $num_rows mysql_num_rows($qry);
        
    $per_col ceil($num_rows/3);
        echo 
    $per_col;
        
    $cnt 1;
        
    $no 1;
        
    $data "<tr><td>";
        while(
    $row mysql_fetch_object($qry))
        {
            if(
    $cnt $per_col+1)
            {
                
    $data .= "$no$row->Names<br />";
            }
            else if(
    $cnt == $per_col+1)
            {
                
    $data .= "</td>";
                
    $data .= "<td>";
                
    $data .= "$no$row->Names<br />";    
                
    $cnt 0;            
            }
            
            
    $cnt++;
            
    $no++;
        }
        
    $data .= "</tr>"
    you can see the results here
    http://www.usabanklocations.com/index.php

    Its seems OK, but just look at the top and bottom of column 1 and 2 they are not aligned.

  2. #2
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    my logic was good, i just set the CSS of the page (i.e. vertical alignment = top) and things are fine !


Bookmarks

Posting Permissions

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