这是我的代码。它从mysql创建xml文件..
我的问题:
for($i=0; $i<count($str_exp1); $i++) // HERE
{
$str_exp2 = explode(",", $str_exp1[$i]);
$newnode->setAttribute("lat", $str_exp2[0]);
$newnode->setAttribute("lng", $str_exp2[1]);
}
因为不显示所有数据...它只显示最新的一个数据..我找不到哪里有问题..
PS对不起我的英语
0
$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++) // HERE
{
$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>";
}