Friday, April 2, 2010

PHP Code for XML

At my current job I'm writing a lot of PHP scripts to take the load off of our programmers and pass that load to our art dept. Much of the data gets passed as static XML files, which I'm converting to dynamic XML from MySQL via PHP, using the following code:

?php

//The big one to make PHP spit it out as XML

header("Content-type: text/xml");

$mysql_user="dbUser";
$mysql_pass="dbPass";
$mysql_host="dbHost";
$mysql_db="dbDB";
mysql_connect($mysql_host,$mysql_user,$mysql_pass);

mysql_select_db($mysql_db);

$sql_query="SELECT * FROM configTable";

$sql_result=mysql_query($sql_query);


Not the cleanest code, I know, but it works.

No comments:

Post a Comment