How to echo all the elements of an array on a single line, where does the line break at each iteration, although the array? This is the code I was able to come up with, but it prints each element on a new line.
while($row = mysql_fetch_assoc($result)) { echo '<h3> Some text'. $row['user_name'] . '</h3>'; }
h3 is a block element. You can display it in a line without using h3 (maybe use a span ) or creating it as a built-in:
h3
span
CSS
h3 { display: inline; }
This is because <h3> , like other <hx> tags, are block level elements and therefore will appear on their own line. You either use an inline element, such as <span> , or set the display property of the <h3> to display: inline in CSS.
<h3>
<hx>
<span>
Maybe something like this:
echo '<h3>'; while($row = mysql_fetch_assoc($result)) { echo $row['user_name']; } echo '</h3>';
With CSS you can float these elements.
h3 { float: left; }
With PHP, you can output one element containing all of these lines: