Input Field - Initial Value

Hi Everyone!

In a CMS I am creating, I have the fields working to submit the data to the MySQL database. I was just wondering if I can set the initial value of the field to what is currently being displayed. :slight_smile: So far I have tried putting:

[php]

<?php mysql_connect("localhost", "", "") or die(mysql_error()); mysql_select_db("cms_home") or die(mysql_error()); $result = mysql_query("SELECT * FROM botcat_content ORDER BY id DESC LIMIT 1") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo $row['content']; ?>

[/php]

into the initial value field, but that didn’t work :’( . I know that code defiantly works, because it is the same one that displays the data on my homepage :slight_smile: any help would be greatly appreaciated :slight_smile: Thanks in advance! ;D ;D ;D

Hi,

Rather than putting that whole code in the middle of the value attribute, put all but the echo above it somewhere and then do:

<input type="text" name="blah" value="<?php echo $row['content']; ?>" />

Also, try pressing CTRL + F5 or CTRL + R (one of these should refresh your page without cache, in case it was remembering that the field was blank)

I Think I Love You! :smiley: Thanks so much!

Sponsor our Newsletter | Privacy Policy | Terms of Service