Ik wil twee tabellen combineren in een xml met de volgende fomat
<Transaction>
<reference>070410171953</reference> //tabel 1
<customer>Tafel 8</customer> //tabel 1
<TransactionLines>
<product>Bier van het vat </product> //tabel 2
</TransactionLines>
<TransactionLines>
<product>Bier van het vat </product> //tabel 2
</TransactionLines>
<TransactionLines>
<product>Huiswijn wit glas </product> //tabel 2
</TransactionLines>
<TransactionLines>
<product>Psaronefri </product> //tabel 2
</TransactionLines>
<TransactionLines>
<product>Suflaki </product> //tabel 2
</TransactionLines>
</Transaction>
Deze code werkt maat ik moet de 30sec timeout op de server uitzetten, dat kan ik op mijn local maar niet op de online server.
<?php
mysql_connect("localhost", "root", "" );
mysql_select_db("pos");
$sql1 = "SELECT reference, customer FROM receipts ";
$result1 = mysql_query($sql1) or die ( mysql_error() );
$xml_output = "<?xml version=\"1.0\" encoding=\"UTF-16\"?>\n";
$xml_output .= "<Data>\n";
while ($row1 = mysql_fetch_assoc($result1) )
{
$receiptsreference=$row1['reference'];
$xml_output .= "<Transactions>\n";
$xml_output .= "<reference>" . $row1['reference']. "</reference>";
$xml_output .= "<customer>" . $row1['customer'] . "</customer>\n";
$sql2 = "SELECT product FROM orders WHERE reference = $receiptsreference";
$result2 = mysql_query($sql2) or die ( mysql_error() );
while ($row2 = mysql_fetch_assoc($result2) )
{
$xml_output .= "<TransactionLines>";
$xml_output .= "<product>" . $row2['product']. "</product>";
$xml_output .= "</TransactionLines>\n";
}
$xml_output .= "</Transactions>\n";
}
$xml_output .= "</Data>";
$XMLFile = fopen("myxmlfile.xml", "w");
fwrite($XMLFile, $xml_output);
fclose($XMLFile);
?>
Hoe kan ik de script beter, sneller maken zodat niet met de timeout error heb te maken?
Bij voorbaat dank Dimitris