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?

Recommended Answers

All 11 Replies

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

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.

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

HI

Pls post some example screen shot for more reference

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

Hi

The content you have showed is stored in single field in a db or multiple field.

It is stored in a single field..

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>';

<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

<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>

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.