I am using this snippet of JavaScript on one of my web sites: <script language='javascript'>document.write("<a href='http://www.digg.com/submit?phase=2&url="+encodeURIComponent(document.location.href)+"' rel='nofollow'>Digg it</a>")</script> Code (markup): This JavaScript is useful, because it makes it possible for site visitors to Digg each of the pages on this site and I don't have to hard-code the URL of each page into the page itself. Is this possible with PHP? I am using .shtml (shared html) pages. Is it possible to embed a PHP script that will offer the same functionality as this JavaScript? I would prefer to do this function server-side instead of client-side.
look at this page from the php docs. You should be able to use $_SERVER['REQUEST_URI'] or $_SERVER['SCRIPT_NAME'] or __FILE__ Have a look and test it out.
So, in my primitive PHP, it would look like this: <?php echo "<a href=http://www.digg.com/submit?phase=2&url=http://"; echo $_SERVER['SERVER_NAME']; echo $_SERVER['REQUEST_URI']; echo ">Digg it</a>"; echo "<br>"; ?> Code (markup): Thanks Sergeant Hayes!
You would be better using your database to populate the title and story content as well rather than just the basic url. Check some of the news items on my phone site (see recent blog link above) to see what I mean.
What database? What are you using to build the code behind that pretty little tower of graphics in the lower right hand corner of your blog? Can you send me the code snippet? What is the PHP variable for a page title?
All the data on my pages is build from a database, is your site database driven? If its not then my method won't help I'm afraid. The graphics on the right hand side are not auto generated, they are just graphics to allow people to sign up for my feeds.
Most of my sites are flat-files. Can you send me the code that is called by each button? It might make writing some of this PHP easier. Thanks!
There is no code behind the buttons, its all in the html of the page. They are simply links to external sites. Feel free to copy the html if you wish, I copied it from somebody else anyway.