$count = 0;
                $Q = "SELECT (SELECT image_short_name FROM user WHERE username = '$user') as `image_short_name`"
                .",`image_id`,`image`"
                ." FROM `image`"
                ." ORDER BY RAND()"
                ." LIMIT 30";
                $R = mysql_query($Q);



echo "
        <div id ='bg'>
            <div id='context'>

                <table>                       
                    <tr>     
                    ";           
                        while($row = mysql_fetch_assoc($R))
                            {
                                echo "<td>";
                                $image_db = $row['image'];
                                $src = "data:image/gif;base64," . $image_db;
                                echo" <img src=\"$src\"  height='20%' width='20%' class='image' />";
                                echo "</td>";
                                $count++;
                                if($count == 5)       //5 rows
                                {
                                    echo "</tr><tr>"; // Start a new row at 6 cells
                                    $count = 0;
                                }
                            }
                echo " 
                    </tr>
                </table>

            </div>
        </div>   
        ";

1st problem
i am having problem with my table. its printing all image with different size.

2nd problem
i want to print images name too. and iam not sure how to do that.

The image is set in your code to be 20% height and width. As a result, if you have something that is 100 x 100, it will display 20 x 20. If its 1000 x 1000 it will display 200 x 200.

What i suggest you do is make sure that either the images are corrected on upload, so are all the same size, or you make sure they are uploaded the same size.

To display the image name you will either have to have stored its name or use an algorythm to generate a name.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.