Jump to content


Photo

Forms in HTML > MySQL, Outputting a certain style in PHP?


  • Please log in to reply
2 replies to this topic

#1 virtuexru

virtuexru
  • Members
  • PipPipPip
  • Advanced Member
  • 200 posts

Posted 23 May 2006 - 05:56 PM

Hey everyone, this is my dilemma. I have a form (PHP/MySQL) and have people inputting text that they usually copy preformatted with bolds, spaces, new paragraphs and things like that and then paste it into my multi-line form box that will output to a MySQL database.

I was wondering if there is anyway to auto-format these so that they go in formatted as the user has put them in already so they dont have to re-do things?

Here is the actual code for the box.


<form action="insert.php" method="post">
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
<tr bgcolor="#CCCCCC">
<td>Job Details (description):</td>
<td><textarea name="details" cols="60" rows="30">Enter job description here.</textarea></td>
</tr>
</table>
<p/>
<div align="center">
<input type="Submit">
</div>
</form>



The code for the above mentioned "insert.php" is here:


<?
$user="xx";
$password="xx";
$database="xx";
$title=$_POST['title'];
$number=$_POST['number'];
$description=$_POST['description'];
$category=$_POST['category'];
$salary=$_POST['salary'];
$addcomp=$_POST['addcomp'];
$position=$_POST['position'];
$location=$_POST['location'];
$details=$_POST['details'];

mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "INSERT INTO joborder VALUES ('','$title','$number','$description','$category', '$salary','$addcomp','$position','$location','$det ails')";

$result = mysql_query($query);

if($result)
echo "Success!<p/><div align=\"center\">To return to the upload form please click <a href=\"<A href="http://andiamo.andiamopartners.com/form.php\">Here</a></div">xx.com\">Here</a></div>
</p><div align=\"center\">To see results please click <a href=\"xx.com<A href="http://andiamo.andiamopartners.com/output.php\">Here</a></div">\">Here</a></div>";
else
echo "There was an error!<p/>" . mysql_error();
?>

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 23 May 2006 - 07:29 PM

Spaces and new lines will stick as long as you use nl2br() when you do the output. Bolds are another matter altogether and it'll require them to use some kind of tags to get the desired result. You may want to look into something like fckeditor (do a search on the web).

Info: PHP Manual


#3 virtuexru

virtuexru
  • Members
  • PipPipPip
  • Advanced Member
  • 200 posts

Posted 23 May 2006 - 09:21 PM

Amazing, worked perfectly with FCKeditor. Thanks a lot Ober!!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users