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&lt;count($str_exp1); $i++)</code>
<code> { $str_exp2 = explode(",", $str_exp1[$i]);</code>
<code> $newnode-&gt;setAttribute("lat", $str_exp2[0]);</code>
<code> $newnode-&gt;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]
&lt;?php
include("inc/db.php");
$doc = new DOMDocument("1.0");
$node = $doc-&gt;createElement("marker");
$parnode = $doc-&gt;appendchild($node);
$result = mysql_query("SELECT * FROM usersline");
if(mysql_num_rows($result)&gt;0)
{
header("Content-type: text/xml");
while ($mar = mysql_fetch_array($result))
{
$node = $doc-&gt;createElement("line");
$newnode = $parnode-&gt;appendChild($node);
$newnode-&gt;setAttribute("id_line", $mar['id_line']);
$newnode-&gt;setAttribute("color", $mar['colour']);
$newnode-&gt;setAttribute("width", $mar['width']);
$node = $doc-&gt;createElement("point");
$newnode = $parnode-&gt;appendChild($node);
$str_exp1 = explode(";", $mar['coordinats']);
for($i=0; $i&lt;count($str_exp1); $i++)
{
$str_exp2 = explode(",", $str_exp1[$i]);
$newnode-&gt;setAttribute("lat", $str_exp2[0]);
$newnode-&gt;setAttribute("lng", $str_exp2[1]);
}
}
$xmlfile = $doc-&gt;saveXML();
echo $xmlfile;
}
else
{
echo "&lt;p&gt;Ëèíèé íå îáíàðóæåíî!&lt;/p&gt;";
}
?&gt;
&nbsp;
[/code]