beemer832 Posted December 9, 2010 Share Posted December 9, 2010 Scenario: each row contains an ID, title, description, price, and up to 5 images. There are not always 5 images stored in each row. The images are stored as a file path which is then pulled out of the DB and used to display an image via HTML. I need to do some sort of loop/check that looks at the contents of a particular row (actually all rows in this particular table) and then decide how many times to loop through the images to display them all correctly on the webpage. I could statically set a variable for each column but then it would have a space for an image but nothing would show. I really want this to be able to only load the images that are stored in the DB. Any help on how I can go about this? thanks -beemer Quote Link to comment https://forums.phpfreaks.com/topic/221098-checking-to-see-if-all-fields-in-a-row-have-a-value/ Share on other sites More sharing options...
harristweed Posted December 9, 2010 Share Posted December 9, 2010 Put the image path into an array. Count the array. i.e. $images=array(); if((!empty($database_field_1))$images[]=$database_field_1; if((!empty($database_field_2))$images[]=$database_field_2; ...... $number_images=count($images); Quote Link to comment https://forums.phpfreaks.com/topic/221098-checking-to-see-if-all-fields-in-a-row-have-a-value/#findComment-1144839 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.