Autor Zpráva
rouger
Profil *
potrebuju dostat data z databaze do xml a resim to takto:
<? include "../php_scripts/dbconnect.php"; ?>
<?PHP

$query_pocethracu = 'select pocet_hracu from stoly where id = 1';
$results_pocethracu = mysql_query($query_pocethracu);

$query_typhry = 'select typ_hry from stoly where id = 1';
$results_typhry = mysql_query($query_typhry);

$query_jmena = 'select * from hrac where id_stoly=1';
$results_jmena = mysql_query($query_jmena);

echo "<?xml version\"1.0\"?>\n";
echo "<stul>\n";
echo "<pocet_hracu>\n";
echo "" . $results_pocethracu . "\n";
echo "</pocet_hracu>\n";
echo "<typ_hry>\n";
echo "" . $results_typhry . "\n";
echo "</typ_hry>\n";
while($line = mysql_fetch_assoc($results_jmena)) {
	echo "<jmeno>" . $line["meno"] . "</jmeno>\n";
}
echo "</stul>\n";
?>


to mi vygeneruje tohle:

<?xml version"1.0"?>
<stul>
<pocet_hracu>
Resource id #4
</pocet_hracu>
<typ_hry>
Resource id #5
</typ_hry>
<jmeno>meno1</jmeno>
<jmeno>meno2</jmeno>
<jmeno>meno3</jmeno>
<jmeno>meno4</jmeno>
</stul>


coz je spravne az na Resource id #4 a Resource id #5 coz ma spravne hazet cislo a pak string ..
db mam postavenou takto:

create table stoly
(
id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
pocet_hracu mediumint(8),
typ_hry nvarchar(50),
PRIMARY KEY (id)
);

create table hrac
(
id_stoly mediumint(8),
meno nvarchar(20),
FOREIGN KEY (id_stoly) REFERENCES stoly(id)
)

nevite v cem by mohl byt problem ? php zadny chyby nehlasi (asi zacnu pouzivat nakej debuger .p) Dekuji
nightfish
Profil
Resource id #4 a Resource id #5
mysql_result, mysql_fetch_row, mysql_fetch_array
rouger
Profil *
jo dik moc ja si to dal prelozit pres google a uz to chapu :)

nakonec:
$row_pocethracu = mysql_fetch_object($results_pocethracu);
$row_typhry = mysql_fetch_object($results_typhry);

. $row_pocethracu->pocet_hracu .
. $row_typhry->typ_hry .
rouger
Profil *
jako prelozit napovedu na php.net
Toto téma je uzamčeno. Odpověď nelze zaslat.