Check "input type" if value is empty then insert default text

I'm not very advanced so it takes me a long time to get anywhere but I persist and so far have gotten this to work:

<input 
 type="text"
 name="product_desc[<?php echo $language['language_id']; ?>][tab_extra]"
 size ="50"
 value="<?php echo isset($product_desc[$language['language_id']]) ?
       $product_desc[$language['language_id']]['tab_extra'] : ''; ?>"
/>

It looks to the database and displays the value, but allows me to update, delete or change the text that is contained there. Great, except most of the time I need that tab to be called 'Extra' and only rarely will I ever need to change the title. I was thinking of using placeholder but that doesn't really do what I need it to do.

I'm thinking an IF...ELSE statement could work, something like IF tab_extra is empty than display the word 'Extra' by default in the input box. My searches always come up empty because of all the "how do I clear the default value on click" questions that exist, and that's not what I want to do at all.

So to wrap up...look at the database and if the field is empty, add the word 'Extra' to be inserted into the database.

Answers


When selecting from a MySQL database, if you have a table like

table baz:

foo         bar
=========   =========
value1      NULL
value2      Optional
value3      NULL

and want to retrieve the word "Extra" wherever the "bar" column is NULL, then you can use the coalesce function

select coalesce(bar, 'Extra') as bar from baz;

Need Your Help

Delete rows until a defined number?

postgresql numbers delete-row

My server gives me a limit of 10000 rows, and the idea is that I delete all the old rows in a given table and me to leave a certain number of rows.

Associate shadows to their source in image analysis

python gdal ogr

I've got two rasters. The first one corresponds to an cloud mask, that is an image with 1 when the pixel corresponds to a cloud and 0 when it does not. The second is a shadow mask, 1 if the pixel is