usman07 Posted April 13, 2012 Share Posted April 13, 2012 I have php code that is connected to a mysql database and the information and image show but I want to position the image on the left and the text on the right how would i do this, any help is appreciated. { $i = 0; echo '<div style="font-family:helvetica; font-size:15px; padding-left:15px; padding-top:20px;">'; while($row = mysql_fetch_array($result)) { // Loop through results $i++; echo "Displaying record $i<br>\n"; echo "<b>" . $row['id'] . "</b><br>\n"; // Where 'id' is the column/field title in the database echo $row['Location'] . "<br>\n"; // Where 'location' is the column/field title in the database echo $row['Property_type'] . "<br>\n"; // as above echo $row['Number_of_bedrooms'] . "<br>\n"; // .. echo $row['Purchase_type'] . "<br>\n"; // .. echo $row['Price_range'] . "<br>\n"; // .. echo '<img src="'. $row['images'] .'" />'; //image } Quote Link to comment Share on other sites More sharing options...
gristoi Posted April 13, 2012 Share Posted April 13, 2012 echo '<img class="placeMeLeft" src="'. $row['images'] .'" />'; and add this in your stylesheet: .placeMeLeft{ float:left; margin:5px } Quote Link to comment Share on other sites More sharing options...
usman07 Posted April 13, 2012 Author Share Posted April 13, 2012 Thanks for your reply, it still is not placed on the left hand side of the text. its currently beneath the text and still is but has slighty moved to the right because of the padding left. Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 13, 2012 Share Posted April 13, 2012 I think the image would have to come before the text for that float to work. Put the image as the first thing that is printed. Quote Link to comment Share on other sites More sharing options...
usman07 Posted April 13, 2012 Author Share Posted April 13, 2012 thats amazing, it works. thank you both very much! Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 13, 2012 Share Posted April 13, 2012 thats amazing, it works. thank you both very much! You're welcome. If you want the next one to be on a new line, you'll probably want to have <br style="clear: both" /> at the very end, or if you don't have enough text it could keep floating. Quote Link to comment Share on other sites More sharing options...
usman07 Posted April 13, 2012 Author Share Posted April 13, 2012 Thank you! how would I be able to control the text? as in be able to move it more to the right, only the text,cuz at the moment the text and image seem to move together. Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 13, 2012 Share Posted April 13, 2012 What do you mean? Try adding more padding to the image if you want the text over more. Quote Link to comment Share on other sites More sharing options...
usman07 Posted April 13, 2012 Author Share Posted April 13, 2012 like I have the image and text beside each other but I want the text to be a little bit further away from the image, so I changed this padding left: echo '<div style="font-family:helvetica; font-size:15px; padding-left:15px; padding-top:20px;">'; this this moved the image and the text, for some reason, I just want to move the text more to the right. thanks for your help again. Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 13, 2012 Share Posted April 13, 2012 If the text is on the right side of the image, you'll add the padding to the right side of the image, not the left. Quote Link to comment Share on other sites More sharing options...
usman07 Posted April 14, 2012 Author Share Posted April 14, 2012 lol ahhh right Thank you! 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.