Billy's Blog

To post pictures and other goodies for free on the net.

My Photo
Name:
Location: Utah, United States

Born in Kapiolani Children's Medical Center, just a few blocks from Waikiki. Graduated from Kahuku High School. Rode BMX Freestyle for most of my life (more than 20 years), now my 8 year old son is ripping up the skate parks, but plans on getting drafted by the SeaHawks as a WR.

Sunday, February 26, 2012

Pass a PHP variable into JavaScript

Say you need a variable from your PHP code to be used in your JavaScript. A really quick way to do this is to do something like this:

<script type="text/javascript">
var dbElements = "<? echo $dbTotal?>";
</script>

$dbTotal is my PHP variable that is holding the total number of rows in a DataBase. dbElements now contains this value and can be used in my javascript for looping purposes!

0 Comments:

Post a Comment

<< Home