I would like my users to be able to use small parts of of my sites pages on their site. For example: An HTML Table with statistics. Users then insert a line of javascript in their site and my table will display. Can anyone tell me how to do this?
You just need to create a script on your site which might be called with <script src='http://www.mysite.com/data.php' type='text/javascript'></script> Code (markup): data.php will actually output valid javascript but will be created by PHP on the server and will have document.write() type commands to output the correct data. It's not hard once you get your head around it.
Thank you sarahk, I think I almost understand. Don't know how to implement document.write() but I'll do a search.
you use php to do all necessary database connections, information gathering, calculations, etc and you then echo the information with document.write(). This is necessary because when the php script outputs the information to the javascript, the javascript won't know what to do with the it so you use "document.write()" to tell it to write it to the page. This is a sample php file (I called it js.php): <?php $number = 1+2; $name= "three"; echo "document.write('You are using information from mypage.com! visit us now');"; echo "document.write('<br />');"; echo "document.write('number $number is written:$name');"; ?> PHP: This is the html page: <html> <head> <title></title> </head> <body> <script src='http://localhost:8888/js.php' type='text/javascript'></script> </body> </html> HTML: And this is what the html page will output to the user: You are using information from mypage.com! visit us now number 3 is written:three