I am beginner in PHP, I was trying to display the poems which are stored in the database(mysql) to the website with php code, the problem is that the poem is showing as a paragraph....how can I display the poems the way I wanted, like line by line

hi,
exactly i don't know how you want to display the poem

but hope it will help you

first start the query

$query = "select * from tbl_poem";
$result = mysql_query($query) or die('Error in query!<br />'.mysql_error());

// now going to fetch all the result
while($row = mysql_fetch_array($result))
{
echo '<pre>';
echo $row;
echo '</pre>';
}


hope it will help you let me

hi,
exactly i don't know how you want to display the poem

but hope it will help you

first start the query

$query = "select * from tbl_poem";
$result = mysql_query($query) or die('Error in query!<br />'.mysql_error());

// now going to fetch all the result
while($row = mysql_fetch_array($result))
{
echo '<pre>';
echo $row;
echo '</pre>';
}


hope it will help you let me

Hi Jogesh,
thank you for the reply, I used the normal insert query to insert the poem to the db, so it is stored as a paragraph in the db also and when i try to display like this it is displaying like a paragraph, i want it to diplay like this
poem line1.
poem line2.
poem line3.

hello micahgeorge,
can you please write down your insert query here so that understand how you send the data and also tell me which data type you stored in db like blob or text??

hello micahgeorge,
can you please write down your insert query here so that understand how you send the data and also tell me which data type you stored in db like blob or text??

Hi Jogesh,
below is the insert query
$insert=mysql_query("insert into table_poem values($Poem_ID,'$Poem')");
and I used text datatype...

use this and let me know

while($row = mysql_fetch_array($result))
{
echo '<p>'.$row.'</p>';
}

try this way

use this and let me know

while($row = mysql_fetch_array($result))
{
echo '<p>'.$row.'</p>';
}

try this way

Hi Jogesh,
but now also the poem is showing as a paragraph not line by line :(

first depend on you how you insert the data on database

try this also

while($row = mysql_fetch_array($result))
{
 echo nl2br($row['poem']);
 echo '<hr>';
}

let me know

first depend on you how you insert the data on database

try this also

while($row = mysql_fetch_array($result))
{
 echo nl2br($row['poem']);
 echo '<hr>';
}

let me know

Thanks a lot Jogesh, it works :)thanks again

no need to thanks dear

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.