usman07 Posted April 14, 2012 Share Posted April 14, 2012 I basically would like to style the third and fourth echo, could i give it a ID then style it in css, how would i do this? any help is appreciated. my php code: { $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 '<img class="image1" src="'. $row['images'] .'" />'; //image echo "Displaying record $i<br>\n"; echo "<b>" . $row['id'] . "</b><br>\n"; // Where 'id' is the column/field title in the database echo "Location: ". $row['Location'] . "<br>\n"; // Where 'location' is the column/field title in the database echo "Property Type: ". $row['Property_type'] . "<br>\n"; // as above echo "Bedrooms: ". $row['Number_of_bedrooms'] . "<br>\n"; // .. echo "Purchase Type: ". $row['Purchase_type'] . "<br>\n"; // .. echo "Price: ". $row['Price_range'] . "<br>\n"; // .. } Quote Link to comment Share on other sites More sharing options...
sunfighter Posted April 14, 2012 Share Posted April 14, 2012 You can do this a couple of ways: echo "<span style=\"color:red;\">Location: ". $row['Location'] . "</span><br>"; or make a CSS section and do this: echo "<span id=\"location\">Location: ". $row['Location'] . "</span><br>"; The \n is not needed in your code. Quote Link to comment Share on other sites More sharing options...
Drummin Posted April 14, 2012 Share Posted April 14, 2012 You can do this a couple of ways: echo "<span style=\"color:red;\">Location: ". $row['Location'] . "</span><br>"; or make a CSS section and do this: echo "<span id=\"location\">Location: ". $row['Location'] . "</span><br>"; The \n is not needed in your code. You wouldn't use an id as id's need to be unique to the page, and thus would only be valid for one loop. Use a css class instead. Quote Link to comment Share on other sites More sharing options...
usman07 Posted April 14, 2012 Author Share Posted April 14, 2012 thanx to both of you. Im trying to do it for this, but Im doing something wrong? echo "<span style=\"color:green;\"<b>Displaying record $i<br>\n</b><br>'</span>'; Quote Link to comment Share on other sites More sharing options...
Drummin Posted April 14, 2012 Share Posted April 14, 2012 Missing the "greater than" sign and quotes are off. echo "<span style=\"color:green;\"><b>Displaying record $i<br>\n</b><br></span>"; Quote Link to comment Share on other sites More sharing options...
usman07 Posted April 14, 2012 Author Share Posted April 14, 2012 thats brilliant! thank you very much! I want to be able to control the text and move it a little down to be inline with the image, what would be the best way to do this? heres a link to my website: http://www.mumtazproperties.hostei.com/insert.php Quote Link to comment Share on other sites More sharing options...
Drummin Posted April 14, 2012 Share Posted April 14, 2012 Well I am surprised you got it looking like you did without defining the placement of image and text. This is a css issue really, but I would probably use floating div's inside a container div. This is a basic (untested) example of what I'm talking about where image is in one div and text is in another, with a break(clear:both) for each record, inside a wrapper div. I added a padding-top of 10px to the text box. I added an undefined class for each div that you can "style" in your css instead of using inline styling. Again this is just a sample so adjust as needed. echo '<div class="container" style="float:left;">'; while($row = mysql_fetch_array($result)) { // Loop through results $i++; echo '<div class="imageholder" style="float:left;">'; echo '<img class="image1" src="'. $row['images'] .'" />'; //image echo '</div>'; echo '<div class="textholder" style="float:left; padding-top:10px;">'; echo "<span style=\"color:green;\"><b>Displaying record $i<br>\n</b><br></span>"; echo "<b>" . $row['id'] . "</b><br>\n"; // Where 'id' is the column/field title in the database echo "Location: ". $row['Location'] . "<br>\n"; // Where 'location' is the column/field title in the database echo "Property Type: ". $row['Property_type'] . "<br>\n"; // as above echo "Bedrooms: ". $row['Number_of_bedrooms'] . "<br>\n"; // .. echo "Purchase Type: ". $row['Purchase_type'] . "<br>\n"; // .. echo "Price: ". $row['Price_range'] . "<br>\n"; // .. echo '</div>'; echo '<div style="clear:both"></div>'; } echo '</div>'; Quote Link to comment Share on other sites More sharing options...
usman07 Posted April 14, 2012 Author Share Posted April 14, 2012 thats amazing thank you so much for your help! 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.