mysql add some string to several rows

If a column has several rows, i.g.:

'red'  
'NULL'  
'red, yellow'  
'green'  
'NULL'  
'yellow, green'

And you want to add a new string (‘blue’) to every row, so that the result be:

'red, blue'  
'blue'  
'red, yellow, blue'  
'green, blue'  
'blue'  
'yellow, green, blue'

you can use this code

UPDATE my_table 
SET mycolumn = CONCAT('same new string ',mycolumn); 

But the above code works only for rows with some content, not for the empty (NULL) ones. Therefore you can complete your task with the following:

UPDATE my_table 
SET mycolumn = 'same new string' 
WHERE mycolumn IS NULL; 

mysql/php output in utf8

To avoid output problems in non-latin characters you should add this line in a msyqli query (i.e. after $db = mysqli_connect($db_host, $db_user, $db_password, $db_name);):

mysqli_set_charset($db, 'utf8');

import an external table to a mysql table

  • You can use a graphical interface to prepare the rows to insert in mysql table: be careful that a) the number of columns be matching with the mysql table rows number and b) the order of columns be the same.
  • Save your date as csv: in this way you will be able to make further modifications to your data: i.g. you could add new ,NULL,columns (because in librecalc if a column is empty at the end of a file that column is not added).
  • Be very careful with comma (,) within the columns, if you import the table in mysql with comma as column separator. You should avoid commas within a column, if you use commas as separator.
  • In phpmyadmin import your csv file as a new table. As and of line you can set \n if yout line ends with something like “NULL”. Otherwise, if you rows ends with “NULL”, you will get an undesired column at the end of teh impoorted table.
  • Don’t worry if the columns type doesn’t match with the destination mysql table: this is negligible.
  • In sql do this command:

INSERT IGNORE
INTO your_destination_table
SELECT *
FROM the_new_data_table-from-csv;

  • Using insert IGNORE you can avoid to delete the ID beginning column, if it is simply an autoincrement one.
  • Your new rows should have been added to your destination table: done!

Thunderbird chrome not working

If even after adding chrome folder thuderbird doesn’t use your cutomized css, you should try with:

Settings/Options > Advanced > General > Config Editor

toolkit.legacyUserProfileCustomizations.stylesheets > true

center (v and h) an expanded element

It is not easy to center vertically and horizontally an expanded element in a page.

I found this code working for me:

.expansible {max-width: 10vw; 
    transition: all 1s; 
    transition:transform 0.25s ease;}
.expanded {
    max-width: 20vw;
    transform:scale(2.6);
    position: absolute;
    left: 30%;
    top: 25%;
    outline:0;
}    

The image is expended with this js code (put at the end of a file):

document.querySelectorAll('img.expansible').forEach(imageElement => {
  imageElement.addEventListener('click', e => {
    e.preventDefault()
    imageElement.classList.toggle('expanded')
  })
})

and adding the class expansible to the images you want expansible.

problems with an external hard disk

You could have problems with an external hard disk, such as safely removing it (even after unmounting it). In this case you could try this code:

sudo hdparm -Y /dev/[your device: something like sde1 or sdh1]

Another problem could be the impossibility to mount your external hd. In this case, if the hd has an ntfs filesystem, you could try this code:

sudo ntfsfix /dev/[your device]

I found this last code on www.makeuseof.com.

How to hide an empty element

with css

To hide an element you can use css: element:empty (such as p:empty) {display:none}, or img[src=""] {display:none}.

with mysql code

You can, even with PDO, use this syntax

if ($data[0]['somecolumn'] != '') {echo " " . $data[0]['somecolumn'] . "";}