Solved

printing out the data after php while loop

Posted on 2016-11-21
5
39 Views
Last Modified: 2016-11-22
Dear Experts,
I select data from my database which has my stored images paths.
I select them then print them on the screen. However they are not adjacent ( side by side ). Since I use table, every one of them in a  different row.
How can I put them side by side? I tried to do it with <div> but I couldn't.

$sql8 = "SELECT xxxxx FROM resimler where uid='$uid' and ilanid='$ilanid' order by id";
$result8 = $conn->query($sql8);

  
    while($row8 = $result8->fetch_assoc()) {
	
	$id= $row8["id"];
	$ilantarihi= $row8["ilantarihi"];
	$resim= $row8["resim"];
	
	//echo "<div style=width:auto; float:left>
//<img class=kucult src=$resim /> </div>";
		echo "<table><tr><td>
<img class=kucult src=$resim /></td></tr></table>";

Open in new window

0
Comment
Question by:Braveheartli
  • 4
5 Comments
 
LVL 8

Accepted Solution

by:
Mukesh Yadav earned 500 total points
ID: 41897045
Try this ;)

The div element code snippet is correct in this wrap html element attribute values in double quotes(") like:

<div style="width:auto; float:left">
    <img class="kucult" src="https://hrcdn.net/hackerrank/assets/brand/h_mark_sm-05bceb881aa02b72d688d21db01df5d8.png" />
</div>

Open in new window


You can remove double quotes for values have single character or work for multiple works or special characters double quotes are required in this case for style and src double quotes are required you can omit for class.
0
 
LVL 1

Author Comment

by:Braveheartli
ID: 41897053
Dear Mukesh Yadav,
 It's not the case. I don't think it is something to do with double quotes or not.

I think my div or table structure is wrong.
0
 
LVL 1

Author Comment

by:Braveheartli
ID: 41897066
I did it like this:

I created the table out of the while loop, and I close the table again outside of the while loop.

I only used the <td> tag inside the while loop.
It solved my problem.
1
 
LVL 1

Author Comment

by:Braveheartli
ID: 41897636
Actually I need a replace function
I want to replace empty space with something
0
 
LVL 1

Author Closing Comment

by:Braveheartli
ID: 41898209
Thanks for the reply
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
php56-php-mcrypt for rhel7 php56 1 43
How to get bootstrap element to collapse at wider screen width 3 41
Javascript 2 20
Selected in an option list 13 19
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question