Jump to content

Scooby08

Members
  • Posts

    244
  • Joined

  • Last visited

Everything posted by Scooby08

  1. Well what do you know.. Works great now with my original query..
  2. Thanks for the reply! Unfortunately I couldn't get that one to work.. I'm gonna try formatting the timestamp to a datetime format before inserting into the database and see if that works out..
  3. I had this query working before to select all records with a date that was within the next 24 hours, but it wasn't with timestamps.. My timestamps are retrieved from an XML file and look like this: 1265414700000 What do I need to change for timestamps? I also tried this: Thanks!
  4. YES!! That's just beautiful! Way better than what I was doing.. Works great!! Thanks again Thorpe!!
  5. I have a foreach loop that I need the variable to be different if something is true.. This is hard to explain, but an example should work.. It's complete wrong, but should give the idea as to what I'm trying to do.. Have a simple loop: <?php // have a select query here to create the $event_ID_array foreach ($events as $event) { $x = (in_array($event['ID'],$event_ID_array))?'update':'insert'; $sql_$x .= $event['date']; } echo $sql_update; echo $sql_insert; ?> Am trying to collect the data in a string depending on whether that event exists in the database or not.
  6. I am pulling information from an XML file that is ISO-8859-1 encoded and then am inserting that info into a database.. My script is UTF-8 encoded.. The sql has this CHARSET=utf8.. The XML file has some info like so: 4½ And after inserted into the database it's like so: 4½ Just wondering if there's some way I can take care of those so that when they are inserted into the database it doesn't have that funky character in it.. I also have no control over the charset if the XML file..
  7. Indeed you are correct.. I had thought they were the same, but they aren't.. Everything I try runs into another dead end.. Thanks again guys!
  8. Thanks for the quick responses!! That last one gave me this error:
  9. Hello.. I'm trying to figure out a way to combine these first two arrays to get the last array.. 1st array: Array ( [0] => zero [1] => one [2] => two ) 2nd array: Array ( [0] => Array ( [0] => test0 ) [1] => Array ( [0] => test1 ) [2] => Array ( [0] => test2 ) ) The array I'm trying to get out of both: Array ( [zero] => Array ( [0] => test0 ) [one] => Array ( [0] => test1 ) [two] => Array ( [0] => test2 ) )
  10. I did that and then I ran into this problem: 4�.5 I did happen to get this one to finally work though.. preg_replace('/[^A-Za-z0-9]+$/','.5',$string); That one removed all characters that weren't letters or numbers, including that hidden question mark character.. Then it just replaced the ½ at the end.. In my case I will only have ½ if there are fractions, so I can just replace all those with .5.. Thanks for helping out on this one teamatomic!! I really appreciate it..
  11. Its a symbol.. How do you suggest I convert?
  12. Yes I can access it.. I guess I'm missing your point.. Could you explain more? How do I convert the symbol??
  13. Is there a way to combine these two lines to work as one? They both work separately.. <?php preg_replace('/^[0-9]+/','+$0',$string); preg_replace('/[^A-Za-z0-9]+$/','.5',$string); ?> Am checking numbers that could be any of the following (left of "=" is the original and the right is what I'm trying to achieve; the "½" is a special character, not 1/2): 5 = +5 -5 = -5 5½ = +5.5 -5½ = -5.5 I'm rather new to regex so maybe there's a better way to write what I have as well.. Thanks!!
  14. Well I don't have control over that as well.. I didn't make the xml file.. Can't touch it whatsoever..
  15. So how's that done?? preg_match are you meaning??
  16. I would but I don't have control over how the xml is feeding me the fraction.. Am receiving them like so: 4½ Not like so: 4 1/2
  17. I was just wondering if php can convert a fraction that I'm getting from an xml feed.. The fractions are like so: 4½ Otherwise I was thinking of doing a str_replace like so: str_replace('½','.5',$fraction); But that gave me another problem.. It comes out like so: 4�.5 Any suggestions how I could just get 4.5? Thanks!!
  18. Alrighty guys!! Thanks a ton!!
  19. I'm getting a timestamp from an xml feed that I'd like to display in proper date format, but I'm not quite sure how to read this one.. The xml gives a 13 digit timestamp like so: 1263708279364 Here's where I'm at: <?php echo date('m/d/y h:i:s',1263713664290); // 06/22/01 11:54:26 ?> Now if I remove the last 3 digits I get this: echo date('m/d/y h:i:s',1263713664); // 01/17/10 12:34:24 And that seems to be correct.. I guess the question is can the original timestamp that is given be formatted, or do I just have to remove the last 3 digits and call it good? Thanks!!
  20. I have this xml: <?xml version="1.0"?> <Schedule NAME="Hockey"> <EventType ID="500"> <Date DTEXT="Wed, Jan 13, 10"> <Event STATUS="Open"> <Competitor NAME="Minnesota"> <At WHERE="Away"/> </Competitor> <Competitor NAME="St. Louis"> <At WHERE="Home"/> </Competitor> <Time TS="1263434700000" TTEXT="9:05p EST"/> </Event> </Date> </EventType> </Schedule> And I'm trying to get this sort of array out of it: Array ( [attr] => Array ( [NAME] => Hockey ) [EventType] => Array ( [attr] => Array ( [iD] => 500 ) [Date] => Array ( [attr] => Array ( [DTEXT] => Wed, Jan 13, 10 ) [Event] => Array ( [attr] => Array ( [sTATUS] => Open ) [Competitor] => Array ( [0] => Array ( [attr] => Array ( [NAME] => Minnesota ) [At] => Array ( [attr] => Array ( [WHERE] => Away ) ) ) [1] => Array ( [attr] => Array ( [NAME] => St. Louis ) [At] => Array ( [attr] => Array ( [WHERE] => Home ) ) ) ) [Time] => Array ( [attr] => Array ( [TS] => 1263434700000 [TTEXT] => 9:05p EST ) ) ) ) ) ) And am trying it like so: <?php $xml = new XMLReader(); $xml->open('test.xml'); while ($xml->read()) { // what to do?? } ?> Could anybody provide some assistance?? I'm really stuck at this point.. I can't even post what I have tried really because it doesn't even work.. Thank you!!
  21. Here's basically what I'm doing.. Database table: CREATE TABLE `pfs_lines` ( `id` int(30) NOT NULL auto_increment, `type` varchar(15) NOT NULL default '', `awayteam` varchar(255) NOT NULL default '', `hometeam` varchar(255) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; index.php <html> <head> <style> #loading { display:none; width:32px; height:32px; background:url(images/ajax-loader.gif) no-repeat; } </style> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#cur_odds').bind('change', function(){ $('#loading').show(); var type = $(this).val(); $.ajax({ type: 'GET', url: 'odds.php', cache: false, async: true, data: 'type=' + type, success: function(lines){ $('#loading').hide(); $('#display_bets').html(lines); } }); }); }); </script> </head> <body> <input type="hidden" name="cur_odds" value="CFB" id="cur_odds" /> <script type="text/javascript"> $(function() { $('#loading').show(); $.ajax({ type: 'GET', url: 'load-odds.php', async: false, success: function(lines){ $('#cur_odds').trigger('change'); } }); }); </script> <div id="loading">Loading...</div> <div id="display_bets"></div> </body> </html> odds.php <?php // database connect $r = mysql_query("SELECT * FROM pfs_lines WHERE type = '".$_GET['type']."'"); while($l = mysql_fetch_array($r)) { echo $l['type'].' - '.$l['awayteam'].' - '.$l['hometeam'].'<br />'; } ?> load-odds.php <?php // database connect $XML_LINES = 'http://client.vdhinc.com/lines.xml'; $xml = simplexml_load_file($XML_LINES); foreach ($xml->sport as $sport) { foreach ($sport as $game) { mysql_query("INSERT INTO pfs_lines (type,awayteam,hometeam) VALUES ('".$sport->attributes()->type."','$game->awayteam','$game->hometeam')"); } } ?> Well if somebody can figure out a way so one wouldn't have to wait for that to load on page load, that's what I'm looking for.. Thanks again!!
  22. Well see that's basically what I've got right now.. As they enter the page they see a loading message and animated loading gif while the latest xml file is loaded and displayed.. This is really all that I'm trying to overcome here.. That few second wait there.. I have seen this on a couple other sites where they always have the latest odds displayed with no wait whatsoever.. I'm trying to figure out how they do that.. Thank you so much for the ideas!! Maybe the iframe might lead me to the answer..
  23. Ahh.. I like that iframe idea to trigger an update, but this still leaves me with a question.. You said to initially feed them the data.. That is the data that needs to be fresh.. How would the initial feed of the data be the freshest without updating?? Are you saying display the old data until the new data updates and then replace it?
  24. Basically... I'm collecting xml data and storing it into a database. Then I'm calling that info from the database using a jquery .ajax function to load and display it on the page.. It all works fine.. The problem... The xml file consists of many sports leagues with odds for each game in that league.. Right now it takes a few seconds to load all that data and put it into the database.. Now when the user goes to the odds page on the site they have to wait a few seconds for all that data to update into the database and then load to display.. What I would like to know... How could I load the latest xml data into the database so that the user does not have to wait?? The closest I've gotten to solving... I've tried running a cronjob every minute, which works great, but that won't work because the cronjob stops right when I turn off my computer.. I need it to run always so the users always have to most recent data.. And I'm not so sure this is the most efficient way of getting it done either.. There has to be some way of getting this done by using ajax or something like that, but I have no clue how to approach this.. I need some strategy.. Could anybody out there give me a few ideas as to how this might be done?? If I didn't give enough information just let me know and I'll try and be more specific.. Thanks everybody!!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.