Pop-Up Window data to be added to mysql data. How?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Zooter
Forum Commoner
Posts: 45
Joined: Tue May 18, 2004 10:46 am
Location: South Africa

Pop-Up Window data to be added to mysql data. How?

Post by Zooter »

Hi,

I've got a page with a textarea that shows data from a column in a table (mysql db). Therefore the text in that textarea is dynamic and shown through a PHP statement. Now I want the user to be able to add data to that existing data, without him/ her being able to modify the exisiting data shown there. I though to have a pop-up window display there when clicking on a button, the user could then enter the new info there, and when press submit, the new data would display together with the old data in the textarea. Then I submit the page and the data would be updated.

Here is the code for the textarea with the data...

Code: Select all

<textarea name="Notes" cols="80" rows="8"  readonly="readonly" id="Notes" style="font-family:Lucida Console" style="font-size:small"><?php while ($row = mysql_fetch_assoc($NotesSearch)) &#123; echo $row&#1111;"nsTime"]." ---> ".$row&#1111;"body"]."\n"; &#125; ?></textarea>
I The table design for this data is I've created an autonumber date field, so everytime I write an entry, it gets timstamped. So I want an insert record on the pop-up window, and then make the query for this textarea refresh so it would display the new set of data...

Is this possible? Any suggestions?
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Try something a bit more efficient than what you have. Try something along the lines of:

Code: Select all

<?php
$link = mysql_connect($host,$name,$pass);
mysql_select_db($DB) or die("Error!");
$query = "SELECT * FROM $table";
$NoteSearch = mysql_query($result) or die(mysql_error());

if (mysql_num_rows($NoteSearch))
{
 $row = mysql_fetch_assoc($NoteSearch);
 $nsTime = $row["nsTime"];
 $body = $row["body"];

 echo '<textarea name="Notes" cols="80" rows="8"  readonly="readonly" id="Notes" style="font-family:Lucida Console" style="font-size:small">$nsTime --> $body</textarea>';
}
?>
Regards


Joe 8)

feyd|added a missing double quote. :)
Post Reply