Page 1 of 1

Formatting image position vith other echoes in echo line

Posted: Wed Nov 16, 2011 4:15 am
by unexperion
Hi, I'm back again with another problem :)
I need help with formatting the echo output. I know the basics - set font size, font color, align text etc... But what I don't know is aligning images...
So, this is the code:

Code: Select all

<div>
<?php

...//conn and query lines... unimportant for this//
	
echo "<div align='left'><a href=\"some href link\">".$row["image"]."</a></div>".('<font size="3" color="white">').$row['article']." <br> " . ('<font size="2" color="white">').$row['art_name']." <br> " . ('<font size="2" color="red">').$row['art_kind']." <br> ";
	echo ('<font size="2">')."<br><br><a href=\"some href link\"><b>link text</b></a>";
	echo "<hr style=color:#FFFFFF width=100% size=1 noshade />";
?>
</div>
When this code runs it gives me picture, (image) - and then UNDER it are the other echoes (even if i didn't put <br>)
But what I need, actually is that the image is LEFT (*image is a square 150x150px) and the other data to the RIGHT of the image , first data top, second in middle, third to the bottom; but all in the same space that the image occupies, not under, - I actually want this whole set formatted like in html, but I don't know how. (I can do it with table, with 2 cells output, maybe, one cell for image only (php1) and other cell for data (php2), but I want to know can I do it in a single div.
I tried to format the <div align, size... etc> and it's not working... I also tried <img align this and that> and it's not working...
How can this be done?
Please help! Thank you!

Re: Formatting image position vith other echoes in echo line

Posted: Wed Nov 16, 2011 7:00 am
by Celauran
<div> is a block item, so it will always cause a line break. Remove the div and float the image left. Also, you should try to avoid mixing semantic markup and presentation; get rid of your deprecated <font> tags and use CSS instead.

Re: Formatting image position vith other echoes in echo line

Posted: Wed Nov 16, 2011 8:56 am
by unexperion
Uff...It's difficult to use CSS styles due to the fact that all three marks have different values/colors/sizes :) - I don't know how to set different styles to each echo part :D )
Please give me an example of floating the image in the echo.

Code: Select all

<?php
echo "<float='left'><a href=\"some href link\">".$row["image"]."</a></div>".$row['article']." <br> " .$row['art_name']." <br> " . $row['art_kind']." <br> ";
?>
Is this ok? It moves the first data from (article) to the right - but other echoed data are still UNDER image. Even when I lose <br> (all of them) it's just in line with "article" data, not formated to the right of the floated image...

I know the principle, bro, but I can't find explantion for it anywhere :)
I need code :)

Re: Formatting image position vith other echoes in echo line

Posted: Wed Nov 16, 2011 9:36 am
by Celauran

Code: Select all

echo "<div style=\"float: left;\"><a href=\"whatever\">{$row['image']}</a></div>etc..."
As I mentioned earlier, you ought to avoid inline styling, but I've done it above simply for the sake of clarity. Once you get things working, you can move the styles to style sheets.

Re: Formatting image position vith other echoes in echo line

Posted: Wed Nov 16, 2011 9:58 am
by unexperion
Thank you!!!
THANK YOU AGAIN!