Welcome to Our Community

Wanting to join the rest of our members? Feel free to sign up today.

Sign Up

php mysql nesting while loops

Discussion in 'Web Design Forum' started by Neil-C, Sep 12, 2010.

  1. Neil-C

    Neil-C New Member

    I'm trying to display a comment thread per design for my graphic design portfolio.

    Below is the code i have at the minute, I hope someone out there can point me in the right direction. I'm relatively new to php so be nice with me. :confused2

    I have 2 tables in my database, one containing all the image paths and description, another table for the comments.



    $get_info_sql "SELECT id, thumb, full_size, description FROM graphic_design";
    $get_info_res mysqli_query($mysqli$get_info_sql) or die (mysqli_error($mysqli));

    $get_comments_sql "SELECT design_id, user_name, user_comment FROM comments WHERE design_id = '".$id."'";
    $get_comments_res mysqli_query($mysqli$get_comments_sql) or die (mysqli_error($mysqli));

    if (
    mysql_get_num_rows($get_info_res) > 0) {
        while (
    $image_info mysqli_fetch_array($get_info_res) {
    $id $image_info['id'];
    $thumb $image_info['thumb'];
    $full_size $image_info['full_size'];
    $description $image_info['description'];
    $display_block .= "<div><a href=\"".$full_size."\"><img src=\"".$thumb."\"/></a><p>".$description."</p>";
            while (
    $comments mysqli_fetch_array($get_comments_res) {
    $design_id $comments['design_id'];
    $user_name $comments['user_name'];
    $user_comment $comments['user_comment'];
    $display_block .= "<p><b>".$user_name.":</b><br/>".$user_comment."</p></div>";

  2. Victorious

    Victorious New Member

    Why not use foreach loop?

Share This Page