Re: <TEXTAREA in and out of the db>

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: Re: <TEXTAREA in and out of the db>
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-14060@lists.php.net to get a copy of this message
Not quite sure what you want to do - but: <?php //----get data FROM DB into <textarea> $sql = "select foo from bar where x=y"; $query = mysql_query($sql,$connect) or die(mysql_error()); while($row = mysql_fetch_array($query)) { $text = $row[database_field_name]; } //----print out data as <textarea value> echo " <form method="POST" action="somescript.php"> <textarea cols="10" rows="25" wrap="virtual" name="content">$text</textarea> </form>"; ?> //----to insert <textarea> content into a DB [avoiding text-files]: <form method="POST" action="somescript.php"> <textarea cols="10" rows="25" name="content">$text</textarea> <input type="submit" name="submit" value="submit"> </form> //----in somescript.php process result if(isset($submit)) { $sql = "insert into foo (database_field_name) values ('$text')"; $query = mysql_query($sql,$connect) or die(mysql_error()); } Cheers Russ On Tue, 6 Nov 2001 15:35:38 +0100 Michiel_Lange@actuera.com wrote: > Hiyas, > > small question: I am doing some things with text-fields. Now I worked a bit > and I can put the text from the database in the <TEXTAREA> field. so far so > good. > Now, when I put this in a form, and added a nice submit button, I wanted it > to send the field to the database, but somehow I cannot access the data in > the > textarea. So now I try to do it with a file and see what happens, but still > nothing: > > <FORM METHOD="post" ACTION=saveit.php?fname=<?php print($filename); ?>> > <TEXTAREA ROWS=40 COLS=80 NAME=content> > <?php > -> a loop that prints all the lines, did that, worked nice <- > ?> > </TEXTAREA> > <INPUT TYPE=SUBMIT bla bla> > </FORM> > > ----------------- > > saveit.php: > > <?php > $pfile="/tmp/$fname"; > if(file_exists($pfile)) > { > print("$fname had to be deleted first.<BR>"); > unlink($pfile); > } > $fp=fopen($pfile,"w"); > print("Content:<BR>"); > print("$content"); > fputs($fp,htmlspecialchars($content) . "\n"); > fclose($fp); > > when I get this working, I can easily dump it in a database... it's the > textarea that is nagging me now :( > > Met vriendelijke groet, > > Michiel Lange > ActuEra B.V. > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > #-------------------------------------------------------# "Believe nothing - consider everything" Russ Michell Anglia Polytechnic University Webteam Room 1C 'The Eastings' East Road, Cambridge e: r.j.michell@apu.ac.uk w: www.apu.ac.uk/webteam www.theruss.com #-------------------------------------------------------#

« previous php.db (#14060) next »