proctk Posted July 15, 2007 Share Posted July 15, 2007 Hi The below code gets album names from one table then looks in another table of the files that belong in that album. The problem that I'm having is if there is nothing in the table image_files then the data from the table album does not show. I want it to show the album even if its blank. the data would show and the spot for the image would be blank. thankyou for any help thank you <?php // get photo albums $query_get_albums_name = ("SELECT * FROM albumNames WHERE user_id = '$user_id'"); $get_albums_name = mysql_query($query_get_albums_name)or die("SQL Error: $query_get_albums_name<br>" . mysql_error()); while($albums_name = mysql_fetch_assoc($get_albums_name)){ $foundAlbum = $albums_name['album']; //Get & group photos $query_get_albums = ("select * from image_files WHERE user_id = '$user_id' AND album = '$foundAlbum' GROUP BY `album`"); $get_albums = mysql_query($query_get_albums)or die("SQL Error: $query_get_albums<br>" . mysql_error()); while($album=mysql_fetch_assoc($get_albums)) { $query_photo_count = mysql_query("SELECT * FROM `image_files` WHERE `album` = '$album[album]'") or die(mysql_error()); $photo_count=mysql_num_rows($query_photo_count); ?> <table class="columntable" style="border:3px solid #EBEBEB;"> <tr> <td rowspan="6" style="width:25%; padding-right:10px; padding-left:10px;"><img src="../user_images/<?php echo $album['image_name']; ?>" width="150" height="110" alt="<?php echo $album['image_name']; ?>"/></td> <td style="width:75%; color: #5e49d9; font-weight:bold; font-size:16px;"><?php echo $album['album']; ?></td> </tr> <tr> <td style="color:#C4C4C4; font-style:italic;"><?php echo $photo_count; ?> photos</td> </tr> <tr> <td><?php echo $albums_name['albumDetails']; ?></td> </tr> <tr> <td>Location:<?php echo $albums_name['location']; ?></td> </tr> <tr> <td>Create Date: <?php echo $albums_name['createdate']; ?> </td> </tr> <tr> <td><a href="#">Edit Album</a> | <a href="#">Veiw Album</a></td> </tr> </table> <?php } }?> Quote Link to comment Share on other sites More sharing options...
infid3l Posted July 15, 2007 Share Posted July 15, 2007 You could check if $album['image_name'] holds a value, and if not, make give it a value like "blank.gif" with just a white square or something. <?php if (!$album['image_name']) { $album['image_name'] = "blank.gif"; } ?> Quote Link to comment Share on other sites More sharing options...
proctk Posted July 15, 2007 Author Share Posted July 15, 2007 it has to do with the sql statement that searches for the album. if its a new album that was setup then there would be no information in the table image files. Quote Link to comment Share on other sites More sharing options...
dbillings Posted July 15, 2007 Share Posted July 15, 2007 Your syntax is wrong in your sql statement. $query_get_albums = ("select * from image_files WHERE user_id = '$user_id' AND album = '$foundAlbum' GROUP BY ` should be // I don't know what criteria you wanted to group by so I chose user_id but you were missing // a double quote and a parenthesis. You don't need to use parenthesis but if you use one you // need to close it with another. $query_get_albums = ("SELECT * from image_files WHERE user_id = '$user_id' AND album = '$foundAlbum' GROUP BY user_id"); good luck Quote Link to comment Share on other sites More sharing options...
dbillings Posted July 15, 2007 Share Posted July 15, 2007 woops I didn't see the scroll bar, but here's another error. query_photo_count = mysql_query("SELECT * FROM `image_files` WHERE `album` = '$album[album]'") lose the single quotes around image_files and album like this. query_photo_count = mysql_query("SELECT * FROM image_files WHERE album = '$album[album]'"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.