displaying multiple mysql records in one html row using php

Discussion in 'Software' started by radiot, Oct 2, 2004.

  1. radiot

    radiot Private First Class

    Howdy folks,

    I am trying to get three rows from a mysql query result to print in three seperate columns in one row of an html table.

    I used a tutorial and came up with:



    <?php

    $result = mysql_query("
    SELECT
    A.ID,
    A.style,
    A.tn,
    A.desc
    FROM
    A
    WHERE
    A.ID >0");
    if($r = mysql_fetch_array($result))
    {
    print("<table>");
    print("<tr>");
    $num = @mysql_num_rows($result);
    $thumbcols = 3;
    $thumbrows = 1+ round($num / $thumbcols);
    function display_table() {
    global $num, $result, $thumbrows, $thumbcols;
    for($r=1;$r<=$thumbrows;$r++) {
    print '<tr>';
    for($c=1;$c<=$thumbcols;$c++) {
    print '<td bgcolor="#999999" align="center" valign="top">';


    printf("<a href=\"%s?ids=%s\"><img src=http://foobar.com/foobar/styles/%s></a><br>\n", $PHP_SELF, $r["ID"], $r["tn"]);
    printf("<a href=\"%s?ids=%s\">%s</a><br>\n", $PHP_SELF, $r["ID"], $r["style"]);


    print("</td>");
    }
    print("</tr>");
    }
    }
    display_table();
    print("</table>");
    }
    else {
    print '&nbsp;';
    }
    ?>

    Problem is, this prints a very long list of imageless tn's.

    Any ideas??? Suggestions much appreciated.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds