Forum Moderators: open
There is also an htaccess file that tells the server to treat xml files as php.
The XML displays perfectly however the job I'm doing requires that the XML feed automatically refreshes every 2 hours without the user manually refreshing the page.
Is this possible?
Here's the code I'm using in the .xml file:
<?php
//for the output
header("Content-type: text/xml");
//to create connection to database
$connection = mysql_connect('', '', '')
or die ("could not connect to database");
//to select the database here test is the sample database come with mysql
$db = mysql_select_db("",$connection)
or die ("Couldn't select database.");
$rs = mysql_query("select * from ",$connection)
or die ("invalid query");
//count the no. of columns in the table
$fcount = mysql_num_fields($rs);
$xml ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
//you can choose any name for the starting tag
echo ("<result>");
while($row = mysql_fetch_array( $rs ) )
{
echo ("<tablerow>");
for($i=0; $i< $fcount; $i++)
{
$tag = mysql_field_name( $rs, $i );
echo ("<$tag>". $row[$i]. "</$tag>");
}
echo ("</tablerow>");
}
echo ("</result>");
?>
Can you explain in very plain words exactly what occurs in each step of the process? Not your code, I understand the code, it's the general step-by-step process I am trying to get my head around here.
In a nutshell the code in the original post is in a file named xml.xml I just want that page (mysite.com/xml.xml) to automatically refresh in the same way as the active posts list page does on webmasterworld (ie on its own without the user refreshing the page through the browser.)
Hope this makes it clearer, if it doesn't don't worry about it mate and thanks for your help.