Results 1 to 3 of 3

Thread: php and html

  1. #1
    Join Date
    Aug 2009
    Posts
    74
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default php and html

    <div id='sss' class='col'>
    <h4>for sale</h4>
    <div class='cats'> <div class='cats'><ul id='ccc1'>
    ";
    $res=mysql_query("select * from post_subtypes where postid=16");

    while($var=mysql_fetch_array($res))

    {

    echo"<li><a href=sale1.php?id=$var[cid]><font size=2> $var[name]</font></a></li>";
    }
    echo"</ul>
    </div>
    </div>
    ------------------------------------------------------------------------
    when i do this i will get my required values in a single row. what I want is to get them in two rows (half in one row and the other half in another row)

    any suggestions plz

  2. #2
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    I did this the other day. Thing is I used it for an array, not a mysql db, but I changed it for mysql, hopefully this'll work. Here you go:

    PHP Code:
    <div id='sss' class='col'>
    <h4>for sale</h4>
    <div class='cats'> <div class='cats'><ul id='ccc1'>
    <?php

    echo '<table border="0" cellspacing="10" cellpadding="0" align="center">';

    function 
    print_data($rows$cols$offset) {
        if(
    $rows 0) {

            
    $res mysql_query("select * from post_subtypes where postid=16 LIMIT $offset,$rows");
            
    $offset $offset $cols;
                
            echo 
    "
            <tr>"
    ;
            while(
    $var mysql_fetch_array$res )) {
                echo 
    '
                <td>
                <li><a href="sale1.php?id='
    .$var[cid].'"><font size="2">'.$var[name].'</font></a></li>
                </td>'
    ;
            }
            echo 
    "
            </tr>"
    ;
            
    $rows $rows 1;
            
    print_data($rows$cols$offset);
        }
    }
    echo
    "</ul>";

    $rows 5000//rows to display
    $cols 2//columns to display
    $offset 0// offset, good for paging

    print_data($rows$cols$offset);
    echo 
    "</table>";

    ?>
    </div>
    </div>
    HTH
    - Josh

  3. The Following User Says Thank You to JShor For This Useful Post:

    hemi (09-15-2009)

  4. #3
    Join Date
    Aug 2009
    Posts
    74
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default

    thnks it is working

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
  •