How to fetch data from mysql to XML File [closed]












-1















Im a Amateur in PHP but i have to build a Website with Google Maps API.



I build it with the informations from here: developers.google



The Data with the coordinates is saved in a Table in my Mysql DB.
At this moment i have to run manually a PHP file, which generates / echo a XML on the browser, which i have to save in my htdocs directory.
In a JS script i run a function, which loads the data from the XML for showing the addresses on the map.



The goal is, that i dont have to run manually this PHP file which generates a XML, which i also have to save it manually to the htdocs directory.



This is where im echo'ing de XML Data to the browser:






// Start XML file, echo parent node
echo "<?xml version='1.0' ?>";
echo '<markers>';
$ind=0;
// Iterate through the rows, printing XML nodes for each
while ($row = @mysqli_fetch_assoc($result)){
// Add to XML document node
echo '<marker ';
echo 'id="' . $row['id'] . '" ';
echo 'name="' . parseToXML($row['name']) . '" ';
echo 'address="' . parseToXML($row['address']) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo 'type="' . $row['type'] . '" ';
echo '/>';
$ind = $ind + 1;
}
// End XML file
echo '</markers>';





How can i do this process outomatically? It should be possible but i found nothing on Google.. I searched for "php fetch from mysql to xml" etc. and found alot about how to fetch data from XML to Mysql.



I hope you are able to understand my bad english.



Greetings










share|improve this question













closed as unclear what you're asking by Patrick Q, Progman, Marcin Orlowski, Mark Amery, GhostCat Nov 16 '18 at 7:59


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • 1





    What do you mean by automatically?

    – RiggsFolly
    Nov 15 '18 at 16:30











  • if i open the URL of the Website, it should build a XML-File with the data from MySql. Because if somebody update some Data in the DB, i have to be sure that Google Maps shows all the actual Addresses.

    – Roman Krattiger
    Nov 15 '18 at 16:34











  • Then I assume you will have to get javascript to ask using AJAX for this data every XX seconds so it gets refreshed on your page. Is that what you mean?

    – RiggsFolly
    Nov 15 '18 at 16:36











  • Yes, something like that. Its not necessary to have 100% actual Data on my Website. In this moment, my website doesnt create this XML automatically. Before i open my website, i have to run manually the php file, then save the output (with xml data) to my htdocs directory AND THEN i can open my website. i just need to find something which doesnt echo the XML-Data....something that write this format to a xml-file.

    – Roman Krattiger
    Nov 15 '18 at 16:41













  • @RomanKrattiger You could use require('PAGE URL') in php, this way you would call that php file from another php file to process the script without needing to manually call it each time. Is this what you needed?

    – GrandIQ
    Nov 15 '18 at 16:47


















-1















Im a Amateur in PHP but i have to build a Website with Google Maps API.



I build it with the informations from here: developers.google



The Data with the coordinates is saved in a Table in my Mysql DB.
At this moment i have to run manually a PHP file, which generates / echo a XML on the browser, which i have to save in my htdocs directory.
In a JS script i run a function, which loads the data from the XML for showing the addresses on the map.



The goal is, that i dont have to run manually this PHP file which generates a XML, which i also have to save it manually to the htdocs directory.



This is where im echo'ing de XML Data to the browser:






// Start XML file, echo parent node
echo "<?xml version='1.0' ?>";
echo '<markers>';
$ind=0;
// Iterate through the rows, printing XML nodes for each
while ($row = @mysqli_fetch_assoc($result)){
// Add to XML document node
echo '<marker ';
echo 'id="' . $row['id'] . '" ';
echo 'name="' . parseToXML($row['name']) . '" ';
echo 'address="' . parseToXML($row['address']) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo 'type="' . $row['type'] . '" ';
echo '/>';
$ind = $ind + 1;
}
// End XML file
echo '</markers>';





How can i do this process outomatically? It should be possible but i found nothing on Google.. I searched for "php fetch from mysql to xml" etc. and found alot about how to fetch data from XML to Mysql.



I hope you are able to understand my bad english.



Greetings










share|improve this question













closed as unclear what you're asking by Patrick Q, Progman, Marcin Orlowski, Mark Amery, GhostCat Nov 16 '18 at 7:59


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • 1





    What do you mean by automatically?

    – RiggsFolly
    Nov 15 '18 at 16:30











  • if i open the URL of the Website, it should build a XML-File with the data from MySql. Because if somebody update some Data in the DB, i have to be sure that Google Maps shows all the actual Addresses.

    – Roman Krattiger
    Nov 15 '18 at 16:34











  • Then I assume you will have to get javascript to ask using AJAX for this data every XX seconds so it gets refreshed on your page. Is that what you mean?

    – RiggsFolly
    Nov 15 '18 at 16:36











  • Yes, something like that. Its not necessary to have 100% actual Data on my Website. In this moment, my website doesnt create this XML automatically. Before i open my website, i have to run manually the php file, then save the output (with xml data) to my htdocs directory AND THEN i can open my website. i just need to find something which doesnt echo the XML-Data....something that write this format to a xml-file.

    – Roman Krattiger
    Nov 15 '18 at 16:41













  • @RomanKrattiger You could use require('PAGE URL') in php, this way you would call that php file from another php file to process the script without needing to manually call it each time. Is this what you needed?

    – GrandIQ
    Nov 15 '18 at 16:47
















-1












-1








-1








Im a Amateur in PHP but i have to build a Website with Google Maps API.



I build it with the informations from here: developers.google



The Data with the coordinates is saved in a Table in my Mysql DB.
At this moment i have to run manually a PHP file, which generates / echo a XML on the browser, which i have to save in my htdocs directory.
In a JS script i run a function, which loads the data from the XML for showing the addresses on the map.



The goal is, that i dont have to run manually this PHP file which generates a XML, which i also have to save it manually to the htdocs directory.



This is where im echo'ing de XML Data to the browser:






// Start XML file, echo parent node
echo "<?xml version='1.0' ?>";
echo '<markers>';
$ind=0;
// Iterate through the rows, printing XML nodes for each
while ($row = @mysqli_fetch_assoc($result)){
// Add to XML document node
echo '<marker ';
echo 'id="' . $row['id'] . '" ';
echo 'name="' . parseToXML($row['name']) . '" ';
echo 'address="' . parseToXML($row['address']) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo 'type="' . $row['type'] . '" ';
echo '/>';
$ind = $ind + 1;
}
// End XML file
echo '</markers>';





How can i do this process outomatically? It should be possible but i found nothing on Google.. I searched for "php fetch from mysql to xml" etc. and found alot about how to fetch data from XML to Mysql.



I hope you are able to understand my bad english.



Greetings










share|improve this question














Im a Amateur in PHP but i have to build a Website with Google Maps API.



I build it with the informations from here: developers.google



The Data with the coordinates is saved in a Table in my Mysql DB.
At this moment i have to run manually a PHP file, which generates / echo a XML on the browser, which i have to save in my htdocs directory.
In a JS script i run a function, which loads the data from the XML for showing the addresses on the map.



The goal is, that i dont have to run manually this PHP file which generates a XML, which i also have to save it manually to the htdocs directory.



This is where im echo'ing de XML Data to the browser:






// Start XML file, echo parent node
echo "<?xml version='1.0' ?>";
echo '<markers>';
$ind=0;
// Iterate through the rows, printing XML nodes for each
while ($row = @mysqli_fetch_assoc($result)){
// Add to XML document node
echo '<marker ';
echo 'id="' . $row['id'] . '" ';
echo 'name="' . parseToXML($row['name']) . '" ';
echo 'address="' . parseToXML($row['address']) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo 'type="' . $row['type'] . '" ';
echo '/>';
$ind = $ind + 1;
}
// End XML file
echo '</markers>';





How can i do this process outomatically? It should be possible but i found nothing on Google.. I searched for "php fetch from mysql to xml" etc. and found alot about how to fetch data from XML to Mysql.



I hope you are able to understand my bad english.



Greetings






// Start XML file, echo parent node
echo "<?xml version='1.0' ?>";
echo '<markers>';
$ind=0;
// Iterate through the rows, printing XML nodes for each
while ($row = @mysqli_fetch_assoc($result)){
// Add to XML document node
echo '<marker ';
echo 'id="' . $row['id'] . '" ';
echo 'name="' . parseToXML($row['name']) . '" ';
echo 'address="' . parseToXML($row['address']) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo 'type="' . $row['type'] . '" ';
echo '/>';
$ind = $ind + 1;
}
// End XML file
echo '</markers>';





// Start XML file, echo parent node
echo "<?xml version='1.0' ?>";
echo '<markers>';
$ind=0;
// Iterate through the rows, printing XML nodes for each
while ($row = @mysqli_fetch_assoc($result)){
// Add to XML document node
echo '<marker ';
echo 'id="' . $row['id'] . '" ';
echo 'name="' . parseToXML($row['name']) . '" ';
echo 'address="' . parseToXML($row['address']) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo 'type="' . $row['type'] . '" ';
echo '/>';
$ind = $ind + 1;
}
// End XML file
echo '</markers>';






php mysql xml






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 16:19









Roman KrattigerRoman Krattiger

31




31




closed as unclear what you're asking by Patrick Q, Progman, Marcin Orlowski, Mark Amery, GhostCat Nov 16 '18 at 7:59


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as unclear what you're asking by Patrick Q, Progman, Marcin Orlowski, Mark Amery, GhostCat Nov 16 '18 at 7:59


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1





    What do you mean by automatically?

    – RiggsFolly
    Nov 15 '18 at 16:30











  • if i open the URL of the Website, it should build a XML-File with the data from MySql. Because if somebody update some Data in the DB, i have to be sure that Google Maps shows all the actual Addresses.

    – Roman Krattiger
    Nov 15 '18 at 16:34











  • Then I assume you will have to get javascript to ask using AJAX for this data every XX seconds so it gets refreshed on your page. Is that what you mean?

    – RiggsFolly
    Nov 15 '18 at 16:36











  • Yes, something like that. Its not necessary to have 100% actual Data on my Website. In this moment, my website doesnt create this XML automatically. Before i open my website, i have to run manually the php file, then save the output (with xml data) to my htdocs directory AND THEN i can open my website. i just need to find something which doesnt echo the XML-Data....something that write this format to a xml-file.

    – Roman Krattiger
    Nov 15 '18 at 16:41













  • @RomanKrattiger You could use require('PAGE URL') in php, this way you would call that php file from another php file to process the script without needing to manually call it each time. Is this what you needed?

    – GrandIQ
    Nov 15 '18 at 16:47
















  • 1





    What do you mean by automatically?

    – RiggsFolly
    Nov 15 '18 at 16:30











  • if i open the URL of the Website, it should build a XML-File with the data from MySql. Because if somebody update some Data in the DB, i have to be sure that Google Maps shows all the actual Addresses.

    – Roman Krattiger
    Nov 15 '18 at 16:34











  • Then I assume you will have to get javascript to ask using AJAX for this data every XX seconds so it gets refreshed on your page. Is that what you mean?

    – RiggsFolly
    Nov 15 '18 at 16:36











  • Yes, something like that. Its not necessary to have 100% actual Data on my Website. In this moment, my website doesnt create this XML automatically. Before i open my website, i have to run manually the php file, then save the output (with xml data) to my htdocs directory AND THEN i can open my website. i just need to find something which doesnt echo the XML-Data....something that write this format to a xml-file.

    – Roman Krattiger
    Nov 15 '18 at 16:41













  • @RomanKrattiger You could use require('PAGE URL') in php, this way you would call that php file from another php file to process the script without needing to manually call it each time. Is this what you needed?

    – GrandIQ
    Nov 15 '18 at 16:47










1




1





What do you mean by automatically?

– RiggsFolly
Nov 15 '18 at 16:30





What do you mean by automatically?

– RiggsFolly
Nov 15 '18 at 16:30













if i open the URL of the Website, it should build a XML-File with the data from MySql. Because if somebody update some Data in the DB, i have to be sure that Google Maps shows all the actual Addresses.

– Roman Krattiger
Nov 15 '18 at 16:34





if i open the URL of the Website, it should build a XML-File with the data from MySql. Because if somebody update some Data in the DB, i have to be sure that Google Maps shows all the actual Addresses.

– Roman Krattiger
Nov 15 '18 at 16:34













Then I assume you will have to get javascript to ask using AJAX for this data every XX seconds so it gets refreshed on your page. Is that what you mean?

– RiggsFolly
Nov 15 '18 at 16:36





Then I assume you will have to get javascript to ask using AJAX for this data every XX seconds so it gets refreshed on your page. Is that what you mean?

– RiggsFolly
Nov 15 '18 at 16:36













Yes, something like that. Its not necessary to have 100% actual Data on my Website. In this moment, my website doesnt create this XML automatically. Before i open my website, i have to run manually the php file, then save the output (with xml data) to my htdocs directory AND THEN i can open my website. i just need to find something which doesnt echo the XML-Data....something that write this format to a xml-file.

– Roman Krattiger
Nov 15 '18 at 16:41







Yes, something like that. Its not necessary to have 100% actual Data on my Website. In this moment, my website doesnt create this XML automatically. Before i open my website, i have to run manually the php file, then save the output (with xml data) to my htdocs directory AND THEN i can open my website. i just need to find something which doesnt echo the XML-Data....something that write this format to a xml-file.

– Roman Krattiger
Nov 15 '18 at 16:41















@RomanKrattiger You could use require('PAGE URL') in php, this way you would call that php file from another php file to process the script without needing to manually call it each time. Is this what you needed?

– GrandIQ
Nov 15 '18 at 16:47







@RomanKrattiger You could use require('PAGE URL') in php, this way you would call that php file from another php file to process the script without needing to manually call it each time. Is this what you needed?

– GrandIQ
Nov 15 '18 at 16:47














1 Answer
1






active

oldest

votes


















0














To create the XML file you requested, you would need to write/create the file each time on request.



// This creates the userinfo.xml file and 'w' writes to it.
$xmlfile = fopen("userinfo.xml", "w");
$userData = "USER INFORMATION GOES HERE";
fwrite($xmlfile,$userData);
fclose($xmlfile);


This function will override the file named "userinfo.xml" if it exists and override it with the information passed with $userData, so be cautious before handling writing files.






share|improve this answer
























  • Ok, thank you Sir! But one question...And how can i get the currently output (xml data) to this $userData file? Can i replace the "echo" in my Loop with something that creates my formatted text?

    – Roman Krattiger
    Nov 15 '18 at 17:07













  • @RomanKrattiger Store your text information that you have inside of each Echo into a String, like $userData, then pass it as a parameter when your creating the file in fwrite.

    – GrandIQ
    Nov 15 '18 at 17:10











  • Ok, i will try it. Thanks alot for your help Sir!

    – Roman Krattiger
    Nov 15 '18 at 17:12











  • @RomanKrattiger Your welcome! If this answer helped you don't forget to mark it as Correct/Answer, Thanks!

    – GrandIQ
    Nov 15 '18 at 17:13


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














To create the XML file you requested, you would need to write/create the file each time on request.



// This creates the userinfo.xml file and 'w' writes to it.
$xmlfile = fopen("userinfo.xml", "w");
$userData = "USER INFORMATION GOES HERE";
fwrite($xmlfile,$userData);
fclose($xmlfile);


This function will override the file named "userinfo.xml" if it exists and override it with the information passed with $userData, so be cautious before handling writing files.






share|improve this answer
























  • Ok, thank you Sir! But one question...And how can i get the currently output (xml data) to this $userData file? Can i replace the "echo" in my Loop with something that creates my formatted text?

    – Roman Krattiger
    Nov 15 '18 at 17:07













  • @RomanKrattiger Store your text information that you have inside of each Echo into a String, like $userData, then pass it as a parameter when your creating the file in fwrite.

    – GrandIQ
    Nov 15 '18 at 17:10











  • Ok, i will try it. Thanks alot for your help Sir!

    – Roman Krattiger
    Nov 15 '18 at 17:12











  • @RomanKrattiger Your welcome! If this answer helped you don't forget to mark it as Correct/Answer, Thanks!

    – GrandIQ
    Nov 15 '18 at 17:13
















0














To create the XML file you requested, you would need to write/create the file each time on request.



// This creates the userinfo.xml file and 'w' writes to it.
$xmlfile = fopen("userinfo.xml", "w");
$userData = "USER INFORMATION GOES HERE";
fwrite($xmlfile,$userData);
fclose($xmlfile);


This function will override the file named "userinfo.xml" if it exists and override it with the information passed with $userData, so be cautious before handling writing files.






share|improve this answer
























  • Ok, thank you Sir! But one question...And how can i get the currently output (xml data) to this $userData file? Can i replace the "echo" in my Loop with something that creates my formatted text?

    – Roman Krattiger
    Nov 15 '18 at 17:07













  • @RomanKrattiger Store your text information that you have inside of each Echo into a String, like $userData, then pass it as a parameter when your creating the file in fwrite.

    – GrandIQ
    Nov 15 '18 at 17:10











  • Ok, i will try it. Thanks alot for your help Sir!

    – Roman Krattiger
    Nov 15 '18 at 17:12











  • @RomanKrattiger Your welcome! If this answer helped you don't forget to mark it as Correct/Answer, Thanks!

    – GrandIQ
    Nov 15 '18 at 17:13














0












0








0







To create the XML file you requested, you would need to write/create the file each time on request.



// This creates the userinfo.xml file and 'w' writes to it.
$xmlfile = fopen("userinfo.xml", "w");
$userData = "USER INFORMATION GOES HERE";
fwrite($xmlfile,$userData);
fclose($xmlfile);


This function will override the file named "userinfo.xml" if it exists and override it with the information passed with $userData, so be cautious before handling writing files.






share|improve this answer













To create the XML file you requested, you would need to write/create the file each time on request.



// This creates the userinfo.xml file and 'w' writes to it.
$xmlfile = fopen("userinfo.xml", "w");
$userData = "USER INFORMATION GOES HERE";
fwrite($xmlfile,$userData);
fclose($xmlfile);


This function will override the file named "userinfo.xml" if it exists and override it with the information passed with $userData, so be cautious before handling writing files.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 15 '18 at 16:58









GrandIQGrandIQ

541211




541211













  • Ok, thank you Sir! But one question...And how can i get the currently output (xml data) to this $userData file? Can i replace the "echo" in my Loop with something that creates my formatted text?

    – Roman Krattiger
    Nov 15 '18 at 17:07













  • @RomanKrattiger Store your text information that you have inside of each Echo into a String, like $userData, then pass it as a parameter when your creating the file in fwrite.

    – GrandIQ
    Nov 15 '18 at 17:10











  • Ok, i will try it. Thanks alot for your help Sir!

    – Roman Krattiger
    Nov 15 '18 at 17:12











  • @RomanKrattiger Your welcome! If this answer helped you don't forget to mark it as Correct/Answer, Thanks!

    – GrandIQ
    Nov 15 '18 at 17:13



















  • Ok, thank you Sir! But one question...And how can i get the currently output (xml data) to this $userData file? Can i replace the "echo" in my Loop with something that creates my formatted text?

    – Roman Krattiger
    Nov 15 '18 at 17:07













  • @RomanKrattiger Store your text information that you have inside of each Echo into a String, like $userData, then pass it as a parameter when your creating the file in fwrite.

    – GrandIQ
    Nov 15 '18 at 17:10











  • Ok, i will try it. Thanks alot for your help Sir!

    – Roman Krattiger
    Nov 15 '18 at 17:12











  • @RomanKrattiger Your welcome! If this answer helped you don't forget to mark it as Correct/Answer, Thanks!

    – GrandIQ
    Nov 15 '18 at 17:13

















Ok, thank you Sir! But one question...And how can i get the currently output (xml data) to this $userData file? Can i replace the "echo" in my Loop with something that creates my formatted text?

– Roman Krattiger
Nov 15 '18 at 17:07







Ok, thank you Sir! But one question...And how can i get the currently output (xml data) to this $userData file? Can i replace the "echo" in my Loop with something that creates my formatted text?

– Roman Krattiger
Nov 15 '18 at 17:07















@RomanKrattiger Store your text information that you have inside of each Echo into a String, like $userData, then pass it as a parameter when your creating the file in fwrite.

– GrandIQ
Nov 15 '18 at 17:10





@RomanKrattiger Store your text information that you have inside of each Echo into a String, like $userData, then pass it as a parameter when your creating the file in fwrite.

– GrandIQ
Nov 15 '18 at 17:10













Ok, i will try it. Thanks alot for your help Sir!

– Roman Krattiger
Nov 15 '18 at 17:12





Ok, i will try it. Thanks alot for your help Sir!

– Roman Krattiger
Nov 15 '18 at 17:12













@RomanKrattiger Your welcome! If this answer helped you don't forget to mark it as Correct/Answer, Thanks!

– GrandIQ
Nov 15 '18 at 17:13





@RomanKrattiger Your welcome! If this answer helped you don't forget to mark it as Correct/Answer, Thanks!

– GrandIQ
Nov 15 '18 at 17:13





Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python