0

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

2
Contributors
9
Replies
10
Views
6 Years
Discussion Span
Last Post by jogesh_p
0

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

0

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.

0

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

0

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

0

use this and let me know

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

try this way

0

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

1

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

0

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

This topic has been dead for over six months. 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.