Jump to content

Displaying HTML code help in a mysql database


bedted

Recommended Posts

Hi,

 

I'm sure this is a simple question but one I've been tearing my hair out at.

 

Basically I've got the contents of my frontpage held in a mysql database and its formatted with HTML Tags. When I view the frontpage eveything is fine.

 

I know want to create a page that will lets admin users update the frontpage by editing the HTML code stored in the database.

 

The problem lies when trying to extract the data back out and display it in a form where they can edit it.

 

As the code is formatted in HTML it contains lots of " " " e.g.

 

 

==========================================================

<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">

<tr>

<td width="100%"><p align="justify"><strong><u>

==========================================================

 

etc etc etc

 

So when I put it into the 'value' part of my edit page it doesn't work properly due to the ( " " " ").

 

I'm extracting the information like the below:

 

<?php $sql = "SELECT body FROM frontpage WHERE frontpage_id = 1"; $result = @mysql_query($sql); $row = @mysql_fetch_array($result, MYSQL_NUM);

$body = $row[0];

 

and then using this to input it into the form:

 

<textarea rows="30" cols="108" name="frontpage" value="<?php echo $body; ?>"></textarea>

 

I'm sure it must be possible to get the code into the form as it should be but I'm stumped so I hope someone can help!

 

Thanks in Advance

 

"A very stuck"

Ed Glover

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.