Digg Spy Like: XML & DB Version
Thanks to Blab List for their great tutorial, I was able to create digg-spy like ajax script.
I created two version: Using XML as a source of data and MySQL DB as a source.
Demos:
Here is the XML version: http://lab.mrayyan.com/spy_xml/
And DB Version: http://lab.mrayyan.com/spy_db/
if you want a ready copy that is ready to be used, here you go:
DIGG SPY-LIKE XML Download
DIGG SPY-LIKE DB Download
As for tutorial and explanation, please refer to blab list as a source, since they get all the credit for this.
Print This Post
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.
Comments
I tried it on IIS and had to fixup the sajax_get_my_uri() function by adding
$REQUEST_URI = $_SERVER['SCRIPT_NAME'];
if ($_SERVER['QUERY_STRING'] != ”) {
$REQUEST_URI .= ‘?’.$_SERVER['QUERY_STRING'];
} before the return since IIS doesn’t have the REQUEST_URI var.
It looks like the pollids.length at the bottom of spy.js is a leftover and needs to match data coming from the database instead to show if there is pending data to show.
For some reason on mine the processDB() javascript function is getting called on the timer but I’m not making it into the GET_zips($x) php function so nothing ever gets grabbed from the db.
I’ll play more and let you know what I find.
Thanks,
Will
Got it to work straight out ‘of the box’ as it was. Excellent resource. Did some slight DB tweaks and will play around with it some more to see what is what.
I need to add some limits as my database only had about 200 items and once it hit 201 it started printing out ‘UNDEFINED’ rather than quitting.
Any news on escaping the UNDEFINED problem (any workarounds?)
thanks! worked straight out of the box.
![]()
-Matt
But this scripts keeps showing the same data over and over again, Digg only shows new information. It’ll be great if the XML version could check on the new data and show only that.
I can add that extra feature for you.
All it takes is adding a variable that will be triggered once the last part of the xml has been displayed.
Give me few days till I am done with this other project, and I will get to you.
Hey morad, I got an idea floating in my head, maybe that’s a nice addition to your script:
I want to take several rss feeds from different sites (maybe all interesting rss feeds about cars or games or whatever) and create a little “news spy” website. So the script should read all those rss feeds and show them in the “digg spy” style.
Do you think that’s possible?
Pat: Yeah that is a nice idea. and yes it is possible..where we can take rss feeds into arrays and shuffle it or display them by pubDate…
let me take care of it this weekend…
thanks
Sounds perfect to me. I have read this post with a great pleasure. You should write much more often.

I can’t seem to get the db version working correctly. I changed the function to return return $result = “1″ . ” | ” . “2″ . ” | ” . “3″ . ” | ” . “4″ . ” | ” . “5″; and I still get nothing on my screen. The xml version works perfectly. Is the returned data supposed to contain anything special?