therealwesfoster Posted September 3, 2008 Share Posted September 3, 2008 I'm wanting to create a snippet of js-code that people can use on their website that will generate a picture (linked from my database) and have it link to the page of that image. Basically it's just like what adsense is (for an example). Let me know your thoughts! Wes Quote Link to comment Share on other sites More sharing options...
lemmin Posted September 3, 2008 Share Posted September 3, 2008 You can't query your database with javascript so you will have to use a different language. Quote Link to comment Share on other sites More sharing options...
therealwesfoster Posted September 3, 2008 Author Share Posted September 3, 2008 Thanks lemmin. Would I be able to do something like this? ---- <script type="text/javascript" src="http://site.com/file.js"></script> file.js would actually be a .php file disguised by the wonders of .htaccess. In there I could set the headers to a javascript file and have it output the required javascript... ---- Would that work? If not, even still, how would I use a javascript snippet to generate a clickable image? Quote Link to comment Share on other sites More sharing options...
lemmin Posted September 3, 2008 Share Posted September 3, 2008 If you are going to use PHP anyway, why do you need javascript at all? Your idea would work if the php output a javascript file, but it would be the same as just echoing javascript from a normal php file instead of going through all that extra stuff. I don't think I fully understand your question. Are you looking to do something like this? <?php echo "<script type=\"text/javascript\">"; $qry = mysql_query(...); while ($row = mysql_fetch_assoc($qry)) echo "document.getElementById(".$row['field'].");//do javascript stuff</script>"; ?> Quote Link to comment Share on other sites More sharing options...
therealwesfoster Posted September 3, 2008 Author Share Posted September 3, 2008 Not exactly, but thanks for replying again I'm wanting to give someone a code like this: <script type="text/javascript" src="http://site.com/file.js"></script> And have the linked image show up on their page right where they put that snippet of code. I would use a php snippet, but javascript is alot more widespread (and adsense does it so I know it's possible) Wes Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.