Re: Pre-loading HTML form w/ mySQL data

From: Date: Sat, 20 Jan 2001 15:22:10 +0000
Subject: Re: Pre-loading HTML form w/ mySQL data
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-35803@lists.php.net to get a copy of this message
Do you mean, like if they are editting their profile, their existing one shows up in the text box? Here is a chunk of code I wrote to do that this morning: ------------------------------------------- <?php echo("<form method='POST' action='upload.php?school=$school&teacherusername=$teacherusername'>"); ?> <!-- here is the part you might be looking for --!> <textarea rows="13" name="assignment" cols="51"> <?php $DB_NAME = "hwnet"; //Sets $DB_NAME equal to "hwnet" $connection = mysql_connect("localhost", "youruser", "yourpass"); //Attempts to connect to the server $db = mysql_select_db($DB_NAME,$connection) or die("Couldn't select database!"); //Attempts to connect to the database $sql = "SELECT * FROM $TABLE_NAME WHERE username = '$teacherusername' AND password = '$password'"; // This SQL statement calls up the table and looks for a username and password match the ones specified $result = mysql_query($sql,$connection); while ($row = mysql_fetch_array($result)) { $assignment = $row['assignment']; echo ("Previous assignment:\n $assignment"); } ?> </textarea> <!-- end part your probably looking for --!> <input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p> </form> ------------------------------------------- What this code did was take the existing info in the database, echo it out to a array and then display it inside the text box. - Kath ----- Original Message ----- From: "Anthony Rodriguez" <sbwi@bellatlantic.net> To: <php-general@lists.php.net> Sent: Saturday, January 20, 2001 8:06 AM Subject: [PHP] Pre-loading HTML form w/ mySQL data > I've a mySQL db with user information (e.g.: name, address, phone, etc.). > > I'd like to pre-load an HTML form with the existing user information in > order to enable the users to update some of the information. > > Are there any PHP sample scripts that I may look at to do this? > > Thank you! > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#35803) next »