bitejones Posted September 24, 2011 Share Posted September 24, 2011 Hi, sincerely hope i can get some help here. im pulling some images from my database but i want to display them horizontally for example 3 or 4 images in a row then it moves to a new row. so far i have only being able to display the images vertically. I am not sure if i should be using css or there is a way to do it with php. would appreciate any assistance. I have been tryin to get this done for sometime now and i need to complete this project. I'm new at this Quote Link to comment https://forums.phpfreaks.com/topic/247799-displaying-images-horizontally-with-php/ Share on other sites More sharing options...
Nethox Posted September 24, 2011 Share Posted September 24, 2011 Im not sure how you coded or which variables you've been using but here is an example of a code I made for a photo gallery that displays images in a simple div from left to right. <?php foreach($photos as $photo): ?> <div style="float: left; margin-left: 20px;"> <a href="view.php?id=<?php echo $photo->id; ?>"> <img src="<?php echo $photo->image_path(); ?>" width="200" /> </a> <p><?php echo $photo->caption; ?></p> </div> <?php endforeach; ?> Just change the variables where there are echos to whichever variables you're using. I'm using OOP so my variables appear as $photo->id so perhaps yours would be a simple $id instead. Quote Link to comment https://forums.phpfreaks.com/topic/247799-displaying-images-horizontally-with-php/#findComment-1272470 Share on other sites More sharing options...
bitejones Posted September 24, 2011 Author Share Posted September 24, 2011 Ohh nice, thnx mate! Quote Link to comment https://forums.phpfreaks.com/topic/247799-displaying-images-horizontally-with-php/#findComment-1272477 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.