jon31
08-26-2005, 02:24 PM
hey guys,
I need to write a script that would find a single value from my MySQL database, but from a remote site. I need it for my site www.bedthem.com (http://www.bedthem.com) so that people can put "I've bedded X amount of people".
I think this is usually done with calling a javascript, but I'm not sure how to go about doing this.
Can someone point me in the right direction?
Thanks,
Jon
Burhan
08-27-2005, 02:08 AM
There are a few ways to do this. I suppose the easiest way is to write a script on your site that just prints the result from your database.
Then your members would call this script with their respective memberid/login or some other identifying information.
So, the client would only need to call bedthem.com/stat.php?id=12 and it would print back the result -- like '10'.
Another way to approach this problem is to write a script that returns an image with the number (or any other text that you would like). This would work the same way as remotely hosted counters.
Your client would then put <img src="http://www.bedthem.com/stat.php?id=12" /> and the script would generate an image with the number and print it out.
With the image approach, you can add a few other features, such as different templates for the images, or allow the client to change the colors of the text, etc. etc. as they see fit.
Hopefully this gets you started.
jon31
08-27-2005, 07:43 PM
Hmm.. but the most common use would be for them to put it on MySpace. But they can't just link to a php file, I have to use javascript, don't I? I just want to be able to display a simple text print-out, no fancy stuff :)
HalfBrian
08-28-2005, 04:54 AM
PHP File:
<?php
mysql_connect();
mysql_select_db();
$number = mysql_query();
echo "document.write(\"I've bedded " . $number . " ammount of people\");";
?>
Then your people including it in their MySpace would put:
<script src="http://www.bedthem.com/stats.php?id=11" type="text/javascript"></script>
Hope it helps,
Brian
jon31
08-28-2005, 01:30 PM
Thanks! That works great. I really appreciate it.