Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-20-2005, 02:09 AM
freehits's Avatar
WebProWorld Veteran
 

Join Date: Sep 2004
Location: Posse's On Broadway
Posts: 953
freehits RepRank 0
Default V ticker PHP to jscript help pls

Code:
v_content=[
['http://www.smartmenus.org/other.php','Welcome to the V-NewsTicker example page!','_blank'],
['','Featuring:  blah, blah , blah, blah ....','_blank'],
['http://www.smartmenus.org/','Get the most advanced navigation system for your site - the SmartMenus.','_blank']
];
So the v-ticker 2.2 uses the 3 variables for the three instances that show on the news-ticker.

How can I insert php in to the JS, as to use php and mysql to fill this part of the javascript from a database.

while my php is passable, my JS is not, I have not worked with them together before in this way.
Reply With Quote
  #2 (permalink)  
Old 08-23-2005, 10:27 AM
WebProWorld Pro
 

Join Date: May 2004
Location: Austin, TX
Posts: 199
steve0 RepRank 0
Default

Not sure which part of that is the variable..
but.. something like:

<?php
$foo=mysql_query("SELECT var1, var2, var3,var4,var5 FROM TABLE WHERE some='thing' LIMIT 1");

$bar=mysql_fetch_object($foo);
?>
v_content=[
['<?= $bar->var1 ?>','<?= $bar->var2 ?>','_blank'],
['','<?= $bar->var3 ?>','_blank'],
['<?= $bar->var4 ?>','<?= $bar->var5 ?>','_blank']
];
__________________
Hardcore Programming Solutions and Coffee Drinker
Reply With Quote
  #3 (permalink)  
Old 08-23-2005, 03:04 PM
WebProWorld 1,000+ Club
WebProWorld Moderator
 

Join Date: May 2004
Location: Austin, TX
Posts: 1,331
jestep RepRank 0
Default

Whatever you need to do, your php will be completely parsed before the javascript is ever looked at.

If you make your javascript do what you want it to, and then put your php tags directly within the javascript.

Ex:
<?PHP
$var = "here";
?>

<script>
javascript code goes <?PHP echo "$var"; ?>;
</script>
Reply With Quote
  #4 (permalink)  
Old 08-23-2005, 03:36 PM
freehits's Avatar
WebProWorld Veteran
 

Join Date: Sep 2004
Location: Posse's On Broadway
Posts: 953
freehits RepRank 0
Default

I was under the impression that I cannot plant PHP variables into the script this way, that they would ruin the JS and be misinterpreted or not work as variables.

I also just relized the related issue that I wont be able to store my .JS in a external file since it needs to be inside of a .PHP page to process.

I really dont think I want all that JS in my actaul pages code.
Reply With Quote
  #5 (permalink)  
Old 08-24-2005, 03:16 PM
WebProWorld 1,000+ Club
WebProWorld Moderator
 

Join Date: May 2004
Location: Austin, TX
Posts: 1,331
jestep RepRank 0
Default

You can always tell your server to treat .js files as php files and parse them. Im not sure how the executing would work, as I've never quite done it like that. I'm sure it would work if the javascript was on the same page, but I dont know how a server would treat it if it were external.

The php will work fine inside your javascript as long as it doesn't create incorrect script. I have used it on several websites.
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0