1st - this code here prints random image from database. but i need help print random images but no repeating images.
2nd queestion is that how can i use this code to print image name. too.         

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

    while($row = mysql_fetch_assoc($R))
                                        $image_db = $row['image'];
                                        $src = "data:image/gif;base64," . $image_db;
                                        echo"<img src=\"$src\"  height='15%' width='15%' class='image_p' /> ";

You could save the unique image id to an array or string, then check that array or string for the current unique image id, if it is not there, print the image.

Also, when you say image name, do you mean the file name or a name stored in the database?