0

Hi,
I am fetching data from the database.but I want to fetch it in proper format on PHP page.
Suppose i insert some data like.
1)chair
2)bed
3)sofa
n when i fetch it comes like that
1)chair2)bed3)sofa

But i want to do in proper format.
1)chair
2)bed
3)sofa
Need suggestion?

5
Contributors
11
Replies
12
Views
6 Years
Discussion Span
Last Post by jacob21
0

It's very simple...just while fetching data write in the sequence in which you need data...
For example:-

<?php
//database connection  string
$result=mysql_query("SELECT * FROM table_name")
or die("Query error");
echo "<table>";
echo "<th>Chair</th><th>Bed</th><th>Sofa</th>";
while($row=mysql_fetch_array($result))
{
echo "<tr><td".$row['chair']."</td><td>".$row['bed']."</td><td>".$row['sofa']."</td></tr>" ;
}
echo "<table>";
?>

Hope it's clear...
PS-If your problem is solved mark the thread as solved

0

Thanks but my problem is not like that.Chair,table is not a fixed entity.

suppose Take below example, admin insert some details in that format in database so when i fetch this data it should be in same format like below

We are PwC and let us introduce ourselves to you.

1. The Firm:

PricewaterhouseCoopers Pvt. Ltd. provides industry - focused tax and advisory services to build public trust and enhance value for its clients and their stakeholders.

PwC professionals work collaboratively using connected thinking to develop fresh perspectives and practical advice.

0

What mean the proper format ? Sorting, order or what ? Please be more precise will be appreciate for us.

0

I am inserting below data in the database.what i want to do,when i am fetching below data from database on my php page,its comes in unformatted manner i.e no white spaces,no special symbol showing.

I need to get data on my php page in the same format as i insert.
Thanks


1)
- Contributing to analysis and decision-making of strategic functional architecture objectives of specific projects

- Managing complex projects from inception to implementation
2)

- New business implementations in emerging markets

- Launching new products in established cash and derivative markets

- New business initiatives requiring new legal entities and trade processing flows

0

assuming the field you inserted the data into is named info, then instead of something like: echo $row['info']; try: echo '<div style="white-space:pre">' . htmlentities($row['info'],ENT_QUOTES) . '</div>'; OR: echo '<pre>' . htmlentities($row['info'],ENT_QUOTES) . '</pre>';

Edited by hielo: n/a

0
<div style="padding-bottom:20px; font-size:small; padding-right:28px; ">Description:<?php echo '<div style="white-space:pre" width:200px;>' . htmlentities($row['description'],ENT_QUOTES) . '</div>';?></div>

its not working

0

<div style="padding-bottom:20px; font-size:small; padding-right:28px; ">Description:<?php echo '<div style="white-space:pre; width:200px;">' . htmlentities($row['description'],ENT_QUOTES) . '</div>';?></div>

Edited by hielo: n/a

0

I got answer using nl2br function
Using echo nl2br($row)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.