Oke well i am trying to get all the info from my table pongo and have it written to a xml file
now i got it to get one row but not all the rows like it should ( DISC LIMIT 40)
Also i do not following what youre trying to tell me with
Code: Select all
$myarray = array();
while($rows = mysql_fetch_array($result))
{
if($rows['Empresa'])
{
$myarray[] = "\t<Empresa>="" . $rows['Empresa'] . "">\r\n";
$myarray[] = "\t</Empresa>\r\n";
}
else
{
// something...
}
}
This will surely mess up my well formatted XML document. i gave it some thought and even a try. and ass i expected it did mess up my xml formae
Any other ideas on how to get all the 40 rows ?
Or else by $date say like only today?!
let me show the whole script as i got it now.
Code: Select all
<?
$hoy = date("F d Y");
$dbase ="home";
$tablename ="pongo";
$connect= mysql_connect('localhost')
or die("Cant connect: " .mysql_error());
// connectarse con el base datos
mysql_select_db($dbase, $connect);
// consultar el tabla pongo ( cambiar cuando listo )
// Only execute this code if the Paqnr variable isset
$query = "SELECT Empresa, Paqnr, Codigo, Envio, Desde, Information, Comentario, Peso_Total, Valor, Codigo_Env, Peso FROM pongo ORDER BY `Empresa` DESC LIMIT 40";
// $result = mysql_query($query);
// if($row = mysql_fetch_array($result))
// {
$result = mysql_query($query) or die (mysql_error());
$num = mysql_num_rows($result);
if ($num != 0)
{
$file= fopen("resulta.xml", "w");
$_xml ="<?xml version="1.0" encoding="UTF-8" ?>\r\n";
$_xml .="<Caudat_xml>\r\n";
if ($rows = mysql_fetch_array($result))
{
$_xml .="\t<num_paquete>="" . $rows["Paqnr"] . "">\r\n";$_xml .="\t</num_paquete>\r\n";
$_xml .="\t<empresa>="" . $rows["Empresa"] . "">\r\n";$_xml .="\t</empresa>\r\n";
$_xml .="\t<codigo>="" . $rows["Codigo"] . "">\r\n";$_xml .="\t</codigo>\r\n";
$_xml .="\t<envio>="" . $rows["Envio"] . "">\r\n";$_xml .="\t</envio>\r\n";
$_xml .="\t<desde>="" . $rows["Desde"] . "">\r\n";$_xml .="\t</desde>\r\n";
$_xml .="\t<peso_total>="" . $rows["Peso_Total"] . "">\r\n";$_xml .="\t</peso_total>\r\n";
$_xml .="\t<peso>="" . $rows["Peso"] . "">\r\n";$_xml .="\t</peso>\r\n";
$_xml .="\t<valor>="" . $rows["Valor"] . "">\r\n";$_xml .="\t</valor>\r\n";
$_xml .="\t<codigo_env>="" . $rows["Codigo_Env"] . "">\r\n";$_xml .="\t</codigo_env>\r\n";
$_xml .="\t<informacion>="" . $rows["Information"] . "">\r\n";$_xml .="\t</informacion>\r\n";
//$_xml .="\t<dato="" .$hoy. "">\r\n";$_xml .="\t</dato>\r\n";
}
else
{
$_xml .="\t<Query_Empty>="No Resulta">\r\n";
$_xml .="\t</Query_Empty>\r\n";
}
}
$_xml .="</Caudat_xml>";
fwrite($file, $_xml);
fclose($file);
echo "XML formato list. <a href="resulta.xml">Por Aqui el formato XML.</a>";
?>
as you can see below it only displayed one row, as it should retrieve like 40 rows
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
- <Caudat_xml>
<num_paquete>="777000"></num_paquete>
<empresa>="mycom"></empresa>
<codigo>="899"></codigo>
<envio>="to"></envio>
<desde>="from"></desde>
<peso_total>="9807435"></peso_total>
<peso>="98769876"></peso>
<valor>="876976"></valor>
<codigo_env>=""></codigo_env>
<informacion>="comnt"></informacion>
</Caudat_xml>
its should be like this
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
- <Caudat_xml>
// first $row
<num_paquete>="777000"></num_paquete>
<empresa>="mycom"></empresa>
<codigo>="899"></codigo>
<envio>="to"></envio>
<desde>="from"></desde>
<peso_total>="9807435"></peso_total>
<peso>="98769876"></peso>
<valor>="876976"></valor>
<codigo_env>=""></codigo_env>
<informacion>="comnt"></informacion>
// second $row
<num_paquete>="22222"></num_paquete>
<empresa>="mycom2"></empresa>
<codigo>="999"></codigo>
<envio>="tomambo"></envio>
<desde>="frommambo"></desde>
<peso_total>="90000"></peso_total>
<peso>="90000"></peso>
<valor>="$500"></valor>
<codigo_env>=""></codigo_env>
<informacion>="comnt"></informacion>
ect..... with the other 38 $rows
</Caudat_xml>