Division von Datenbankfeldern



Mit dem /-Operator lassen sich im SQL-Statement Zahlen dividieren.


<?php

$servername = "yourservername";
$username = "yourusername";
$password = "yourpassword";
$dbname = "yourusername";

$con = mysqli_connect($servername,$username,$password,$dbname);

$res = mysqli_query($con, "SELECT zahl001, zahl002, zahl001 / zahl002 AS zahl003 FROM rechnen");
$num = mysqli_num_rows($res);
if($num > 0) echo "";
else echo "Keine Ergebnisse<br>";

echo "<br><table><tr><td>Zahl0011</td><td>Zahl002</tD><tD>Zahl003</td></tr>"; while ($dsatz = mysqli_fetch_assoc($res))
{

echo "<tr>";
echo "<td>" . $dsatz["zahl001"] . "</tD>";
echo "<td>" . $dsatz["zahl002"] . "</a></tD>";
echo "<td>" . $dsatz["zahl003"] . "</a></tD>";
echo "</tr>";

}

echo "</table>";

mysqli_close($con);

?>



created by NETTECS.ch