Jump to content

Help With Forms


CammyD

Recommended Posts

Hi

Php newbie here.

I need some help with a project i am working on.

It is a kind of Multi Person notepad, so it takes the text you type, saves it, then echos it on the index page.

What i am stuck on here is the <textarea> part.

On that bit, you type in the stuff, hit submit, gets saved then takes you back to the index.

I want to make the textarea echo what is already in the database.

Example:

________

|            |

|            |  <-- Text box          Index.php --> Saved text

|            |

 

 

How do i make what shows up on the index file, show up in the text box?

Link to comment
Share on other sites

<?php include="info.php"; 
$name_of_table="";
$the_where_definition="this='that'";
?>
<form action="process.php" method="post"> 
<textarea name="text">
<?php
echo @current(@mysql_fetch_assoc(@mysql_query("SELECT * FROM $name_of_table WHERE $the_where_definition")));
?>
</textarea>
</br><input type="submit" />
</form>

 

Just change the 2 vars on top for the name of the table and the where definition Ex id='1'

Link to comment
Share on other sites

<?php include="info.php"; 
$name_of_table="my_table";
$the_where_definition="??'";
?>
<form action="process.php" method="post"> 
<textarea name="text">
<?php
echo @current(@mysql_fetch_assoc(@mysql_query("SELECT * FROM $name_of_table WHERE $the_where_definition")));
?>
</textarea>
</br><input type="submit" />
</form>

 

I don't get the  $the_where_definition bit

 

When i hit submit, the text on the index is blank

Link to comment
Share on other sites

if you wana show the stuff in your text area you have to tell him where to find it. most tables has a unique var we call id so you should start by finding out if you have one on your table.

 

Let say you do have the id var to your table and you would like to see the row id number 5 in your textarea you would use id='5'

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.