Ich habe einige PostgreSQL-Abfragen und die Ausgabe sieht wie folgt aus. Jetzt möchte ich diese Ausgabe Abfrage PHP, wie dies zu tun? meine PostgreSQL-Abfrage ist wie folgt:Wie erstellt man eine Tabelle in PHP mit PostgreSQL-Abfragen?
$query = 'select
round(
100.00 *
(sum(case when "WELLTYPE"= 'DT' and ("CONC_ARSC" between 0 and 10) then 1 else 0 end))/(sum(case when "WELLTYPE"= 'DT' then 1 else 0 end)),1) "0-10",
round(
100.00 *
(sum(case when "WELLTYPE"= 'DT' and ("CONC_ARSC" between 11 and 50) then 1 else 0 end))/(sum(case when "WELLTYPE"= 'DT' then 1 else 0 end)),1) "11-50",
round(
100.00 *
(sum(case when "WELLTYPE"= 'DT' and ("CONC_ARSC" >50) then 1 else 0 end))/(sum(case when "WELLTYPE"= 'DT' then 1 else 0 end)),1) ">50",
round(
100.00 *
(sum(case when "WELLTYPE"= 'DT' and ("CONC_ARSC" between 0 and 10) then 1 else 0 end))/(sum(case when ("WELLTYPE"= 'DT' or "WELLTYPE"= 'DW' or "WELLTYPE"= 'FT' or "WELLTYPE"= 'ST') and ("CONC_ARSC" between 0 and 10)then 1 else 0 end)),1) "Total"
from public."Arsenic_Test"';
Die Ausgabe von oben PostgreSQL-Abfrage wie folgt aussieht:
____________________________________________
|0_to_10| 11_to_50 | greater_than_50 | Total|
--------+----------+-----------------+------|
| 100 | 0.0 | 0.0 | 0.4 |
----------------------------------------------
ich bin sehr beginer in php so ich weiß nicht, wie ich anfangen soll. Ich hatte Datenbankverbindung und es funktioniert gut. Ich hatte Array erstellen Tabelle in Web erstellt (mit PHP)
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$db_connection = pg_connect("host=localhost port=5433 dbname=BankeDB user=postgres password=admin");
echo $db_connection;
$query = 'select.... (above query) ';
$result = pg_query($db_connection, $query, $POST);
$result = pg_query($db_connection, $query);
$DT = array('0-10','11-50','>50',total);
$result = pg_query($db_connection, $query);
while ($DT = pg_fetch_row($result)) {
echo "<tr>";
echo "<td>$DT[0]</td>";
echo "<td>$DT[1]</td>";
echo "<td>$DT[2]</td>";
echo "<td>$DT[3]</td>";
echo "<td>$row[4]</td>";
echo "</tr>";
}
echo $result;
pg_close($db);
Bitte posten Sie, was Sie versucht haben, und alle Fehler, die Sie aufgetreten sind. Auch ein Beispiel für die Ausgabe, die Sie wünschen, wäre nett. – ChristianF
Ich bin sehr beginer in PHP so weiß ich nicht, wie ich anfangen soll. Ich hatte Datenbankverbindung und es funktioniert gut. Ich hatte Array erstellt, um Tabelle im Web zu erstellen (mit PHP) – Ram
@ChristianF Ich hatte einige Informationen hinzugefügt, was ich bisher getan habe. Kannst du mir bitte helfen, es zu klären? – Ram