Current location: Hot Scripts Forums » Programming Languages » PHP » PHP and XML (Used for lottery statistics)


PHP and XML (Used for lottery statistics)

Reply
  #1 (permalink)  
Old 08-19-04, 05:32 AM
v1brazy v1brazy is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Newcastle - UK
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Question PHP and XML (Used for lottery statistics)

Hya everyone!

I have been developing a website about the lottery (for personal use), where I study statistics on numbers, draws etc.

The data in the website is held on a mysql DB and I use PHP to retrieve, format and execute my functions to display my results.

Now I have converted all the contents of my Database into a XML file (drawResults.xml) and all I need to do now Is to use PHP to work with XML and display the same results without using mysql.

---- contents in my xml file ----
<list>

<draw>
<day>W</day>
<b1>30</b1>
<b2>3</b2>
<b3>5</b3>
<b4>44</b4>
<b5>14</b5>
<b6>22</b6>
<bball>10</bball>
<drawDate>19/11/1994</drawDate>
</draw>


<draw>
<day>S</day>
<b1>16</b1>
<b2>6</b2>
<b3>44</b3>
<b4>31</b4>
<b5>12</b5>
<b6>15</b6>
<bball>37</bball>
<drawDate>26/11/1994</drawDate>
</draw>

</list>
----- end of content -----

If anyone is interested my site is www.f34r.co.uk/dan (the lottery charts were taken from a lottery book and Ive developed into a dynamic website)

Can anyone help my putting those XML information in the file into an array

$drawArray[1]=30,10,34,22,1,3,17,20/11/2004
$drawArray[2]=31,11,03,42,21,33,27,25/11/2004

Thank you very much for all your help!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 08-19-04, 10:05 AM
blaw's Avatar
blaw blaw is offline
Junior Code Guru
 
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Hi there,

It looks quite interesting. This *may* be of a help: http://www.php.net/manual/en/functio...nto-struct.php . If not, try creating a SAX parser function. You can start with this: http://www.php.net/xml or if you are not familiar with SAX, read tutes like this first: http://www.wdvl.com/Authoring/Langua...prophp4_5.html .

Good luck!
__________________
Blavv =|
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 08-19-04, 12:00 PM
v1brazy v1brazy is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Newcastle - UK
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Talking

Hya all,

I have now managed to do it!!

The reason why I wanted to switch to XML instead of Mysql is because I thought it was gonna be faster, but It seams that they take the same time to process.

If anyone is interested i used the following code:
---------------------------
<?php
// make drawArray[0] = 10,12,13....,W,19/12/2004

$all_draws_xml = array();
$drawArray = array();


function character_data($parser, $data) {
// make all_draws_xml array and populate with all the results
global $all_draws_xml;

if ($data == 'W' || $data == 'S')
{
$all_draws_xml[] = $data;
}
elseif ($data != 0)
{
$all_draws_xml[] = $data;
}

}

function make_draws_array(){

global $all_draws_xml;
global $drawArray;
global $temp;
$temp = 0;

$count = count($all_draws_xml);
$finalVar = ($count / 9);
$increment = 0;

for($i=0;$i<$finalVar;$i++){


for ($z = $increment ; $z < ($increment+9); $z++){

$drawArray[$i][] = $all_draws_xml[$z];

}
$increment += 9;

}
return $count;
}

$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
xml_set_character_data_handler($parser, 'character_data');

$document = file('drawsXml2.xml');

foreach ($document as $line) {
xml_parse($parser, $line);
}

make_draws_array();

?>
----------------
http://www.f34r.co.uk/dan/companion.php (MySql)
http://www.f34r.co.uk/dan/companionXML.php (XML)
-----------
Thx for everybodys help
peace out!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Syndicating XML data into a website using PHP... Jackal05 PHP 3 07-16-04 03:38 PM
RSS/XML Tools written with PHP benruth PHP 0 07-16-04 02:08 PM
javascripting and XML Christoff JavaScript 1 06-23-04 06:44 AM
XML to PHP/HTML Script Request BAFP Script Requests 2 06-12-04 09:09 PM
PHP & XML - any1? mishmia Script Requests 2 06-03-04 05:04 AM


All times are GMT -5. The time now is 07:17 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.