0

Thi si probably a really simple thing to solve but I am failry new to PHP and cannot find the answer anywhere.

I have a search results page that calls data from a MYSQL database. All of the correct information is displaying but one of the fields contains text on different rows.

When the PHP displays the results all of the line breaks are removed. Is there a way of stopping this?

The current code I am using is:
<?php echo $row_jobdetails; ?>

Thanks

9
Contributors
10
Replies
14
Views
7 Years
Discussion Span
Last Post by nishchal_619
0
<?php echo "\n".$row_jobdetails['job_description']; ?>

Thank you for the quick reply - unfortunately the text is still all on the same line.

0

What is the content reside in the description? you mean the text from the description is all having no link breaks? do you post your code?

Edited by rajarajan07: n/a

0

You could always concantenate "<br />" to your 'job_description' field within the SQL statement. like this...

SELECT 
        job_id, 
        job_title, 
        job_description + '<br />' AS job_description
FROM tblTableName

...this way when your job_description field is displayed it will automatically break to the next line.

OR

<?php echo $row_jobdetails['job_description']; ?><br />

Edited by bhartman21: n/a

0

I'm not really a php man so the syntax may not be quite correct, but I think you're maybe looking for something like this...

<?php echo str_replace("\n","<br />",$row_jobdetails['job_description']); ?>

Edited by mikev2: n/a

0

while($row_jobdetails = mysql_fetch_array($result)) {

echo $row_jobdetails;
echo "<br>";
}

0

but the line spaces as you would in phpMyAdmin

echo nl2br($row_jobdetails['job_description']);
0

The answer above is how I do it. The function nl2br() was created specifically for this sort of thing.

0

Hello,
Try using the nl2br(); function. It should help if I interpreted your question right. nl2br(); replaces newlines with <br /> tags.

nl2br($variable);

Edited by Chosen13: n/a

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.