salt de línia: <br> <?php echo “hello wold1 <br> hello world 2”;
– //es fa la conexió amb la BD
$conn= mysqli_connect(DB_HOST, DB_USER, DB_PWD, DB_NAME);
//s’escriu a la BD
$SQL =”UPDATE $taula SET castella=’$castella’ WHERE id= ‘$idx’ “;
$result = mysqli_query($conn,$SQL);
//llegir registres d’una taula de BD ( include(‘conexió&results.php’);
$conn= mysqli_connect(DB_HOST, DB_USER, DB_PWD, DB_NAME);// fa la conexió
$conn->set_charset("utf8mb4");
$result = mysqli_query($conn,$SQL);//llegeix i carrega matriu
$num_results = $result->num_rows;
Llegir una fila d’una taula
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', 'beseit00');
DEFINE ('DB_NAME', 'polidic_eng');
$conn = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
OR die (‘Could not connect to MySQL:’ .mysqli_connect_error());
$conn->set_charset(“utf8mb4”);
//echo “Host information: ” . mysqli_get_host_info($conn) . PHP_EOL;
$SQL = “SELECT * FROM parametres WHERE id=1 LIMIT 1”; //ordre mysql
$result = mysqli_query($conn,$SQL);//llegeix i carrega matriu
$camps = mysqli_fetch_assoc($result);
$encerts=$camps[‘compt_encerts’];
$fallades= $camps[‘compt_fallades’];
$total= $encerts + $fallades;
echo “encerts: $encerts, fallades:$fallades”;
$puntuacio= round(($encerts/$total)*10,2);
afegir un registre
$SQL = "INSERT INTO $_POST[taula](catala,castella,qualificador,aux)VALUES( '$catala','$definicio','$qualificador','$aux')";
if (mysqli_query($conn, $SQL)) {echo "New record created successfully";}