Jump to content

Organizing Data within MySQL?


SchweppesAle

Recommended Posts

basically I'm trying to use a Text Area form to post each resume within a LONGTEXT column.  The data is entered correctly, it just loses all formating-how would I go about correcting this? 

 

index.php which contains the form

<form action="Insert.php" method="post">
Name: <input type="text" name="Name" />
<br/>
Number: <input type="text" name="Number" />
<br/>
Resume: <TEXTAREA name = "Resume" ROWS = 47 COLS = 110 wrap = physical></TextArea>
<br/>
<Font size = -1>Maximum of 500 characters</Font>
<br/>
<input type="submit" Value= "Submit Resume" >
</form>

 

Insert.php


<?php

include("Connect.php");
DBConnect();
mysql_select_db("Jobs");

$Name = $_POST['Name'];
$Number = $_POST['Number'];
$Resume = $_POST['Resume'];

mysql_query("INSERT INTO AvailableJobs 
(Name, Number, Resume) VALUES('$Name', '$Number', '$Resume') ") 
or die(mysql_error());  

echo("Data Inserted");
?>

 

 

 

Link to comment
Share on other sites

if you're talking about the newline formatting and tab characters, chances are the data isn't losing it.  it's just ignored when it gets output to HTML.  some functions that might help are:

 

nl2br() (use when outputting, not when saving)

 

also have a look into the

<pre>

tag, which will preserve the simple whitespace formatting such as tab characters.

Link to comment
Share on other sites

just a heads up do not do inserts without properly escaping the data into the database first.

 

not exactly sure what that means. 

 

Also the nl2br function seems to have helped but everything which was aligned to the right hand side of each resume is instead moved a line down.  :-\

Link to comment
Share on other sites

could it be that things aligned right are now outside of the allowable width?  try echoing the resume's text within those pre tags, and see what they look like.

 

@cooldude: while encouraging data cleaning is useful, please stick to the question at hand, otherwise you derail the thread.

Link to comment
Share on other sites

sweet~! thanks a lot guys, looks like that did the trick.  Set a width within the pre element and everything came out just the way I entered it.  One last question before we let this thread die though-the current code I'm using for the html form:

 

<form action="Insert.php" method="post">
Name: <input type="text" name="Name" />
<br/>
Number: <input type="text" name="Number" />
<br/>
Resume: <TEXTAREA name = "Resume" ROWS = 47 COLS = 110 wrap = physical></TextArea>
<br/>
<Font size = -1>Maximum of 500 characters</Font>
<br/>
<input type="submit" Value= "Submit Resume" >
</form>
<a href = "Query.php"> Query </a>

 

It seems users are unable to push the tab button without changing over to a different form.  Also, if I copy and paste anything from openoffice writer it doesn't seem to preserve the alignment of all the text entered.  Is there a quick fix for this?

Link to comment
Share on other sites

the text element field and textarea field don't allow the characters of \n or \t to show (and some others) you can write in \n or \t into it to get them in there.

 

damn, i'm such a noob :P

 

 

Should probably go find a good book on Javascript. Might help me throw some of these ideas together.  I'm not sure my boss' clients would be thrilled if we told them to throw in a \n here and there to make sure their resume is lined up correctly.  Gonna have to try something else I guess.

Link to comment
Share on other sites

that's a flat-out lie.  textareas will process \n and \t.  chances are they are converted to different characters when input into openoffice.  if you'd like to give the user an option to insert a tab character, your best bet is to copy and paste it.  unfortunately, tab is too valuable a button for application browsing.

 

if you input \n and \t directly, it won't work, but that's because those aren't the characters you want to input.  those will be considered the actual characters (backslash and letter).

 

copying and pasting from other sources has always been tricky for textareas.  rule of thumb is the way it looks in notepad = the way it will look in textarea and pre.  if you'd like to offer them more options for formatting (and copying from other sources), perhaps have a look into tinyMCE, a rich HTML editor that you can slot into the form.

Link to comment
Share on other sites

that's a flat-out lie.  textareas will process \n and \t.  chances are they are converted to different characters when input into openoffice.  if you'd like to give the user an option to insert a tab character, your best bet is to copy and paste it.  unfortunately, tab is too valuable a button for application browsing.

 

if you input \n and \t directly, it won't work, but that's because those aren't the characters you want to input.  those will be considered the actual characters (backslash and letter).

 

copying and pasting from other sources has always been tricky for textareas.  rule of thumb is the way it looks in notepad = the way it will look in textarea and pre.  if you'd like to offer them more options for formatting (and copying from other sources), perhaps have a look into tinyMCE, a rich HTML editor that you can slot into the form.

 

thanks dude, that actually sounds like a good idea.  I'll look into it now.

Link to comment
Share on other sites

i will warn you that in order to get tinyMCE working the way you want it, you're going to have to invest a fair bit of time tinkering with little nuances in the HTML that it gives you for storage.  is there a reason you're using the copy/paste method rather than allowing users to upload their resumes?

Link to comment
Share on other sites

i will warn you that in order to get tinyMCE working the way you want it, you're going to have to invest a fair bit of time tinkering with little nuances in the HTML that it gives you for storage.  is there a reason you're using the copy/paste method rather than allowing users to upload their resumes?

 

..... .... *crickets*

 

alright, we'll do it your way. lol

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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