calculate age from year of birth

There are two ways:

via php

## 2. in php
You can also use php code, as in the following way
(inspired from this page (https://stackoverflow.com/questions/3776682/php-calculate-age), and _slighty modified_: 

    $dob =”$row[anno_nascita]”;
    $age = date_diff(date_create($dob), date_create(‘now’))->y;
    echo “age: $age years
“;

via mysql in phpmyadmin

1.do this sql query:
     select *,year(CURDATE())-year(anno_nascita) age from studenti__classi; 
2. save the result as view
3. and so you will have, in the view, the age (of your students, i.g.) that can work in LibreBase (to connect with that view).

linguaggio PHP includere un file remoto

Il comando “include url/nomedelfileremoto” non è sempre accessibile, ed è comunque dispendioso di risorse.
Ho trovato questo comando

<?php
echo file_get_contents(‘http://exempe.com/filename.php’);
?>

Molto utile, ad esempio per condividere dei links tra diversi siti gestitidallo stesso webmaster.
L’ho visto su questo sito.
Occorre che il server supporti la funzione allow_url_fopen (allow_url_fopen=on).

problema in php/mysql

General error: 1032 Can’t find record in ‘nome_table’.

I permessi sono giusti, il problema è un difetto nella table: basta utilizzare la funzione repair table di phpmyadmin alla tabella che presenta errori.

php: attenzione alla sintassi

Sfasature nella resa del codice php possono venire da errori di sintassi, che spingono il server php a ignorare tale codice.
Seglialiamo ad esempio l’inizio delle righe di codice: non basta <? occorre <?php. Attenzione!