Hi Guys,
I have a small problem and was wondering if someone might be able to help me with it.
I have an sql table containing address, phone and email details which are then displayed on the contact us page of the site.
I am designing a basic CMS element that will allow these to be updated. When the user goes to this page, I want the existing details to be echoed into the text boxes.
My problem is that whilst it works for the email and phone variables, I am having trouble getting the address to work. This is the code I am currently using;
$link=mysql_connect('localhost','username','password');
mysql_select_db('database');
$getitem = mysql_query("SELECT address, phone, email FROM user_setting")
or die(mysql_error());
while ($code = mysql_fetch_object($getitem)) {
$address=$code->address;
$phone=$code->phone;
$email=$code->email;
echo "
<form action='./setcontact_submit.php' method='post'>
<br />
<label for='address'>Contact Address</label><textarea name='address' name='address' rows=10 cols=40 value=$address></textarea>
<br />
<label for='phone'>Contact Phone</label> <input type='text' name='phone' id='phone' maxlength='100' class='form_input' value=$phone />
<br />
<label for='email'>Contact Email</label> <input type='text' name='email' id='email' maxlength='150' class='form_input' value=$email />
<br />
<label> </label><input type='submit' value='Submit' class='button' /></form>";}} ?>
I'm thinking it might have something to do with there being newline tags in the address. Because if I echo it into the textarea using nl2br then it kind of works, but obviously there are <br /> tags in it.
I want it to appear as it would appear on the website.
I hope that makes sense and I will be eternally grateful for any help anyone can give me.
Thanks,