Welcome visitor
* Login
* Register
It is currently July 23rd, 2019, 7:17 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Server Side » PHP



Post new topic Reply to topic  [ 3 posts ] 
Author Message
  XML on PHP
PostPosted: February 4th, 2009, 9:23 pm 

Posts: 46
Hi, I have a question. The thing is that i do already have a MySQL database, but since im trying to use flash, im realizing that i need to create a complete new database, and because mine is a huge database it would take forever to finish it. So, instead of doing that im thinking that I can use PHP to kind of automate the process, still im little confused about that. So if you can bring a piece of light to my problem youll make a stressed person very happy :lol:


Top
 Profile  
 
  Re: XML on PHP
PostPosted: February 4th, 2009, 10:03 pm 
User avatar

Posts: 79
Actually is a very easy thing to do. You should only have a PHP file that has its output as an XML. To do that you will need to send a clue, like an id or something, to create the XML file only with the information you need. We'll see how to do that later, first lets see the PHP file itself.
<?php
extract ($_GET);
mysql_connect('host' , 'user' , 'password');
mysql_select_db('database');
$dbTable=mysql_query("SELECT * FROM table WHERE id= '$theClue");

echo '<?xml version="1.0" encoding="utf-8"?>
<group>
';

while ($dbRow = mysql_fetch_array($dbTable))
{
extract ($dbRow);
echo "
   <team teamN=\"$team_Number\">
      <name>$team_Name</name>
   </team>\n\n
      ";
}

echo '
</group>';

I hope this lines to be understandable. Now, to call this file at the same time that we send 'theClue' lets see this AS3 lines, supposing our PHP file is Xml.php and 'theClue' is an existing var called 'User_id'
var dbXML:XML;
var loaderOfXML:URLLoader = new URLLoader();
loaderOfXML.load(new URLRequest('Xml.php?theClue='+id));
loaderOfXML.addEventListener(Event.COMPLETE, processXML);//this last funtcion would be to process the XML, so its up to you its content

As you can see, the PHP file receives the User_id and then looks on the database for the entries that match the User_id, suppouse then that on this example it will show only the info related to that user.


Top
 Profile  
 
  Re: XML on PHP
PostPosted: February 5th, 2009, 10:37 pm 

Posts: 46
:lol: never thought I would be so thankful to a virus!! Thanks so much!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

FORUMS » Server Side » PHP


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron