PHP, FOR

Salam.. Mene belə bir komək lazimdi. Deməli: Mən php nin köməyi ilə bazadan informasiyani götürüb xml formatına çevirib istifadə edirəm.. Problem isə burdadır.. [code] <code>for($i=0; $i<count($str_exp1); $i++)</code> <code> { $str_exp2 = explode(",", $str_exp1[$i]);</code> <code> $newnode->setAttribute("lat", $str_exp2[0]);</code> <code> $newnode->setAttribute("lng", $str_exp2[1]); }</code> [/code] burada for mənə bütün sütunların sayına görə nəticəni verməlidir.. Amma sadəcə ən sonuncu tək sətiri göstərir.. Harda səhv edirəm.. Bütün kod budur: [code] <?php include("inc/db.php"); $doc =  new DOMDocument("1.0"); $node = $doc->createElement("marker"); $parnode = $doc->appendchild($node); $result = mysql_query("SELECT * FROM usersline"); if(mysql_num_rows($result)>0) { header("Content-type: text/xml"); while ($mar = mysql_fetch_array($result)) { $node = $doc->createElement("line"); $newnode = $parnode->appendChild($node); $newnode->setAttribute("id_line", $mar['id_line']); $newnode->setAttribute("color", $mar['colour']); $newnode->setAttribute("width", $mar['width']); $node = $doc->createElement("point"); $newnode = $parnode->appendChild($node); $str_exp1 = explode(";", $mar['coordinats']); for($i=0; $i<count($str_exp1); $i++) { $str_exp2 = explode(",", $str_exp1[$i]); $newnode->setAttribute("lat", $str_exp2[0]); $newnode->setAttribute("lng", $str_exp2[1]); } } $xmlfile = $doc->saveXML(); echo $xmlfile; } else { echo "<p>Ëèíèé íå îáíàðóæåíî!</p>"; } ?>   [/code]    

Verilmiş cavablar və yazılan şərhlər (2 cavab var)

Ruslan Butdayev (2013-02-06 14:24:54)
Dovrn icine salanda bele bir error verir.. [code] XML Parsing Error: junk after document element Location: http://nn-gis.com/map/line.php Line Number 3, Column 1:<?xml version="1.0"?> ^ [/code]

VendeTTA (2013-02-06 01:38:13)
$xmlfile = $doc->saveXML(); Bunla dəyiş yoxla $xmlfile .= $doc->saveXML(); Və dövrün içinə sal mütləq. Dövr bitdikdən sonra echo $xmlfile;

Mövzu üzrə bənzər suallara da baxa bilərsiniz.

Skriptləri necə düzəldirlər?

php: tags sistemi

Php bazadan oxumaq

MySQL sorğuda kömək

php-də fərqli cədvəllərdən çağırılmış məlumatları bir arrayda toplamaq

Belə qeydiyyatın qarşısını necə almaq olar ?