Jump to content

Text field with variable stored in database


kfarrar

Recommended Posts

I have a page where a user builds a custom form line by line by selecting a variety of “form elements” on a self submitting page. These form elements are just HTML tables with multiple <input type=”text”> or <textarea>’s which are stored in the MySQL database.

 

Once the user has built the form then they fill in the text areas of each line and save the completed form. The data from each line is saved to the database.

 

The problem is I can’t seem to populate the text areas on the form for viewing because my form inputs have a variable for value=”$example”.

 

EXAMPLE:

If this was on my page of code it will work and echo the contents of field1 into the text area. <textarea name="line_item[]"><?echo $got->field1;?></textarea>

 

But when the same html as above comes from the database then the text area is populated with this  <?echo $got->field1;?>

 

What do I do?

 

Here is the PHP that echo’s the form:

 

 

$query = ("SELECT * FROM auto_save ORDER BY line_order ASC");

$result = mysql_query($query) or die(mysql_error());

 

$line_order = 1.0;

 

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

 

$get_one = mysql_query("SELECT * FROM auto_save WHERE line_order = $line_order");

$got = mysql_fetch_object($get_one);

 

//echo "$got->field1 $got->field2 $got->field3 $got->field4 $got->field5";

 

echo '<table><tr><td width=50 class=linenumber>'.$row['line_order'].'</td><td>'.$row['form'].'</td></tr></table>';

 

$line_order = $line_order + 1.0;

 

}

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.