Inserting a specific (default) value

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
kdidymus
Forum Contributor
Posts: 196
Joined: Tue May 13, 2008 3:37 am

Inserting a specific (default) value

Post by kdidymus »

I am using a PHP form which POSTS data to a PHP routine which uploads information to my database.

What I NEED to do is say to PHP (on CERTAIN fields only) that if there is no input (i.e. the text box is left blank) I want the value 'blank' inserted in to the row. This is because my database stores filenames (minus the .gif suffix) in certain columns. If no picture exists the default is blank.gif which is a 1px by 1px spacer.

i.e. echo "<img border=0 src='$photo1urn.gif'> where $photo1urn is either '1234' or 'blank'.

I've set up the MySQL database to use a default value of 'blank' for the required fields but when I submit my form the $_POST data overwrites the default value.

Am I making any sense?!

Kris.
kdidymus
Forum Contributor
Posts: 196
Joined: Tue May 13, 2008 3:37 am

Re: Inserting a specific (default) value

Post by kdidymus »

Aargh.

Worked it out. Used <imput type='text' value='blank'> in the relevant fields of my PHP form.

Thanks anyway.

KD.
Post Reply