Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to display 4 cells who php and mysql

    hi,

    am trying to list some image data from my mysql database. But i can't seem to work out how to get it into 4 rows and have the data display in order example.

    + image1 + image2 + image3 + image4 +
    | image5 | image6 | image7 | image8 |
    | | | | |

    right now it just goes down

    image1
    image2
    image3
    image4
    ........

    any ideas?
    thanks

    PHP Code:
    <?php


    $conn 
    mysql_connect($host$user$pass)
    OR DIE (
    mysql_error());
    @
    mysql_select_db ($db$conn) OR DIE (mysql_error());



    $sql "SELECT * FROM $table WHERE displaysub='1' ORDER BY image_date DESC LIMIT $offset, $rowsPerPage";
    $result mysql_query ($sql$conn);
    $i=0;
    $str='';
    if (
    mysql_num_rows($result)>0
    {
    while (
    $row mysql_fetch_array($resultMYSQL_ASSOC)) 
    {
    $count=$row['total_votes'];//how many votes total
    $current_rating=$row['total_value'];//total number of rating added together and stored
    $tense=($count==1) ? "vote" "votes";//plural form votes/vote

    $i++;
    $str .= "<table border='1'><tr>";
    $str .= "<tr><td COLSPAN=4>Title: ".$row["title"]." <br /></td></tr>";
    $str .= "<td><a href='/wac/embed.php?image_id=".$row["image_id"]."'>";
    $str .= "<img height=\"100\" width=\"110\" alt=\"click image to view video\" src='/wac/".$row["file_path"]."'>
    </img>
    </a>
    <br />
    </td>"
    ;
    $str .= "<td>


    <ul class=\"star-rating\">"
    .
    "<li class=\"current-rating\" style=\"width:". @number_format($current_rating/$count,1)*25 ."px;\"></li>".
       
    "<li class=\"one-star\">1</li>".
         
    "<li class=\"twotwo-stars\" >1.5</li>".
         
    "<li class=\"two-stars\" >2</li>".
         
    "<li class=\"three-stars\">3</li>".
         
    "<li class=\"fourfour-stars\">3.5</li>".
         
    "<li class=\"four-stars\">4</li>".
         
    "<li class=\"five-stars\">5</li>".
    "</ul>".
        
    "Rateing <strong>".@number_format($current_rating/$count,2)."</strong> [".$count." ".$tense."]<br />";

    $str .= "</td></tr></table><br />";
    }
    print 
    $str;
     

    }

    ?>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Feb 2010
    Posts
    29
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Why can't you show pictures in 1 table, like:
    Code:
    <table>
    <tr>
    <td>PIC1</td> <td>PIC2</td> <td>PIC3</td> <td>PIC4</td>
    </tr>
    <tr>   
    <--- next 4 pictures...
    </tr>
    ....


  •  

    Posting Permissions

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