PHP a RadPHP > Obecné
Vycteni hodnot z MYSQL a ulozeni do promenných
(1/1)
Kony:
Ahoj, snazim se pripojit k sobe do MYSQL a vycist hodnoty a ulozit do promennych... Porad mi to nic nevycita a nevim kde delam chybu :
--- Kód: ---$connect = mysqli_connect("192.168.1.249", "kony", "HesloDB", "Domacnost");
$chart_data = '';
{
$chart_data = "{ timestamp:'".$row["timestamp"]."',teplota:".$row["teplota"].", vlhkost:".$row["vlhkost"].", tlak:".$row["tlak"]."}, ";
}
$chart_data = substr($chart_data, 0, -2);
$query2 = "SELECT * FROM dht_venku ORDER BY ID DESC LIMIT 1";
$result2 = mysqli_query($connect, $query2);
$line = mysqli_fetch_assoc($result2);
echo htmlspecialchars($line['teplota'];
echo htmlspecialchars($line['tlak'];
?>
--- Konec kódu ---
------------------
tak uprava a taky nic :
--- Kód: ---<?php
$connect = mysqli_connect("192.168.1.249", "kony", "HesloDB", "Domacnost");
$query = "SELECT * FROM dht_venku ORDER BY ID DESC LIMIT 1";
$result = mysqli_query($connect, $query);
$chart_data = '';
while($row = mysqli_fetch_array($result))
{
$chart_data .= "{ timestamp:'".$row["timestamp"]."',teplota:".$row["teplota"].", vlhkost:".$row["vlhkost"].", tlak:".$row["tlak"]."}";
}
$chart_data = substr($chart_data, 0, -2);
$line = mysqli_fetch_assoc($result);
echo htmlspecialchars($line['teplota'];
echo htmlspecialchars($line['tlak'];
?>
--- Konec kódu ---
< z >:
Kolik ti to vrací hodnot (mysqli_num_rows), jaké chyby (mysqli_error)?
Kony:
Nevim jak napsat aby to vypsalo to co pises
Kony:
--- Kód: ---<?php
$server = "localhost";
$user = "kony";
$pass = "HeslodoDB";
$db = "Domacnost";
$connect = mysqli_connect($server, $user, $pass, $db);
$query = "SELECT * FROM dht_venku ORDER BY ID DESC LIMIT 1";
$result = mysqli_query($connect, $query);
$chart_data = '';
while($row = mysqli_fetch_array($result))
{
$chart_data .= "{ timestamp:'".$row["timestamp"]."',teplota:".$row["teplota"].", vlhkost:".$row["vlhkost"].", tlak:".$row["tlak"]."}";
}
$chart_data = substr($chart_data, 0, -2);
$line = mysqli_fetch_assoc($result);
echo htmlspecialchars($line['teplota']);
echo htmlspecialchars($line['tlak']);
?>
--- Konec kódu ---
fakt uz nevim jak na to
Jedna se mi o to, abych vycetl posledni zaznam teplotu a vlhkost
PS: Tak uz mi to funguje.... nemel jsem v DB zaznam ID a primar klic jsem daval na timestamp a ne na ID
Navigace
[0] Seznam témat
Přejít na plnou verzi