Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAlejandro Carvajal
9,100 Pointshow to reference a variable in html?
I need to add a variable with an ID of cashAmount from a database to an html document, but i don't know what ways i can add it. JavaScript... PHP??
Alejandro Carvajal
9,100 Points@DAVE VARMULANT
here's the code.....
<html><head><meta content="text/html; charset=UTF-8" http-equiv="content-type"><style type="text/css">.lst-kix_list_1-3>li:before{content:"\0025cf "}.lst-kix_list_1-4>li:before{content:"o "}ul.lst-kix_list_1-0{list-style-type:none}.lst-kix_list_1-7>li:before{content:"o "}.lst-kix_list_1-5>li:before{content:"\0025aa "}.lst-kix_list_1-6>li:before{content:"\0025cf "}ul.lst-kix_list_1-3{list-style-type:none}.lst-kix_list_1-0>li:before{content:"\0025cf "}ul.lst-kix_list_1-4{list-style-type:none}.lst-kix_list_1-8>li:before{content:"\0025aa "}ul.lst-kix_list_1-1{list-style-type:none}ul.lst-kix_list_1-2{list-style-type:none}ul.lst-kix_list_1-7{list-style-type:none}.lst-kix_list_1-1>li:before{content:"o "}.lst-kix_list_1-2>li:before{content:"\0025aa "}ul.lst-kix_list_1-8{list-style-type:none}ul.lst-kix_list_1-5{list-style-type:none}ul.lst-kix_list_1-6{list-style-type:none}ol{margin:0;padding:0}table td,table th{padding:0}.c6{margin-left:54pt;padding-top:0pt;padding-left:0pt;padding-bottom:0pt;line-height:1.5;orphans:2;widows:2;text-align:left}.c0{color:#000000;font-weight:400;text-decoration:none;vertical-align:baseline;font-size:12pt;font-family:"Times New Roman";font-style:normal}.c12{color:#000000;font-weight:400;text-decoration:none;vertical-align:baseline;font-size:6pt;font-family:"Times New Roman";font-style:normal}.c11{padding-top:0pt;padding-bottom:0pt;line-height:1.0;orphans:2;widows:2;text-align:right}.c1{padding-top:0pt;padding-bottom:0pt;line-height:1.0;orphans:2;widows:2;text-align:left}.c3{font-size:12pt;font-family:"Times New Roman";color:#000000;font-weight:400;text-decoration:underline}.c5{vertical-align:super;font-size:12pt;font-family:"Times New Roman";color:#000000;font-weight:400}.c8{font-size:12pt;font-family:"Times New Roman";color:#000000;font-weight:400}.c7{background-color:#ffffff;max-width:504pt;padding:22.5pt 54pt 0pt 54pt}.c9{margin-left:54pt;padding-left:0pt}.c4{padding:0;margin:0}.c10{margin-left:54pt}.c2{height:9pt}.title{padding-top:24pt;color:#000080;font-weight:700;font-size:36pt;padding-bottom:6pt;font-family:"Trebuchet MS";line-height:1.0;page-break-after:avoid;orphans:2;widows:2;text-align:left}.subtitle{padding-top:18pt;color:#666666;font-size:24pt;padding-bottom:4pt;font-family:"Georgia";line-height:1.0;page-break-after:avoid;font-style:italic;orphans:2;widows:2;text-align:left}li{color:#000080;font-size:9pt;font-family:"Trebuchet MS"}p{margin:0;color:#000080;font-size:9pt;font-family:"Trebuchet MS"}h1{padding-top:24pt;color:#000080;font-weight:700;font-size:24pt;padding-bottom:6pt;font-family:"Trebuchet MS";line-height:1.0;page-break-after:avoid;orphans:2;widows:2;text-align:left}h2{padding-top:18pt;color:#000080;font-weight:700;font-size:18pt;padding-bottom:4pt;font-family:"Trebuchet MS";line-height:1.0;page-break-after:avoid;orphans:2;widows:2;text-align:left}h3{padding-top:14pt;color:#000080;font-weight:700;font-size:14pt;padding-bottom:4pt;font-family:"Trebuchet MS";line-height:1.0;page-break-after:avoid;orphans:2;widows:2;text-align:left}h4{padding-top:12pt;color:#000080;font-weight:700;font-size:12pt;padding-bottom:2pt;font-family:"Trebuchet MS";line-height:1.0;page-break-after:avoid;orphans:2;widows:2;text-align:left}h5{padding-top:11pt;color:#000080;font-weight:700;font-size:11pt;padding-bottom:2pt;font-family:"Trebuchet MS";line-height:1.0;page-break-after:avoid;orphans:2;widows:2;text-align:left}h6{padding-top:10pt;color:#000080;font-weight:700;font-size:10pt;padding-bottom:2pt;font-family:"Trebuchet MS";line-height:1.0;page-break-after:avoid;orphans:2;widows:2;text-align:left}</style></head><body class="c7"><p class="c11"><span class="c0">August 14, 2017</span></p><p class="c1"><span class="c0">Bernard Bell </span></p><p class="c1"><span class="c0">658 Ridgewood Road</span></p><p class="c1"><span class="c0">Maplewood, NJ 07040-2536</span></p><p class="c1 c2"><span class="c0"></span></p><p class="c1"><span class="c0"> </span></p><p class="c1"><span class="c0">Dear LastName: </span></p><p class="c1 c2"><span class="c0"></span></p><p class="c1"><span class="c0">Our firm, Tax Sale Recovery Services (TSRS), identifies unclaimed funds from the auctioning of delinquent property tax sales and we have located such funds that we believe legally belong to you. </span></p><p class="c1 c2" id="h.gjdgxs"><span class="c0"></span></p><p class="c1"><span class="c8">After a certain period of time the unclaimed funds will be transferred to the county of</span><span class="c0"> countyname. At that point the funds will no longer be claimable. </span></p><p class="c1 c2"><span class="c0"></span></p><p class="c1"><span class="c8">The exact amount of the funds to be recovered is </span><span class="c3">$surplusAmount</span><span class="c0">. We specialize in helping individuals claim these funds before the timeframe expires, and with the entire process.</span></p><p class="c1 c2"><span class="c0"></span></p><ul class="c4 lst-kix_list_1-0 start"><li class="c6"><span class="c0">We do all the work necessary to recover the funds</span></li><li class="c6"><span class="c0">There are absolutely no up-front fees or out-of-pocket fees</span></li><li class="c6"><span class="c0">We only receive a finder’s fee if and when you’re paid</span></li><li class="c1 c9"><span class="c0">Worst case scenario, you don’t owe us anything if funds are not collected</span></li></ul><p class="c1 c2 c10"><span class="c12"></span></p><ul class="c4 lst-kix_list_1-0"><li class="c1 c9"><span class="c0">When an attorney is needed, we cover all legal fees</span></li></ul><p class="c1 c2"><span class="c0"></span></p><p class="c1"><span class="c0">Don’t hesitate to contact us: you can reach one of our associates, Jake Butler, at 305-926-2839 until 7pm daily. Also, feel free to visit our office by appointment located at: </span></p><p class="c1"><span class="c8">1951 NW 70</span><span class="c5">th</span><span class="c0"> Street, Suite 300, Miami, Florida 33136.</span></p><p class="c1 c2"><span class="c0"></span></p><p class="c1"><span class="c0">Tax Sale Recovery Services provides fast, friendly, and dependable service, and we look forward to the opportunity to work with you. </span></p><p class="c1 c2"><span class="c0"></span></p><p class="c1"><span class="c0">Sincerely,</span></p><p class="c1 c2"><span class="c0"></span></p><p class="c1 c2"><span class="c0"></span></p><p class="c1"><span class="c0">Jake Butler, Manager</span></p></body></html>
run it in a browser, I need to replace the $surplusAmount with a specific variable that will be eventually updated from a database. But i have no idea whatsoever on how to plug in that varaiable for $surplusAmount
Dave StSomeWhere
19,870 PointsDon't need to see the whole page - just the element you wish to update. You don't just plug a variable into a page from the browser.
If you are planning to use php, then you will insert your php code to echo the value into the document. Something like:
<?php
// need to get the value somehow
$newAmount = 25.24;
echo '<span class="c3">' . $newAmount . '</span>' ;
?>
Alejandro Carvajal
9,100 PointsI just need a way to add variable x from a table in a database to replace $surplusAmount in the code snippet =
<span class="c8">The exact amount of the funds to be recovered is </span><span class="c3">$surplusAmount</span><span class="c0">. We specialize in helping individuals claim these funds before the timeframe expires, and with the entire process.</span> \**)
This way when i change the variable in the database, then the html will refresh. take into consideration i have no idea on how databases work. But i want to find out the best, and most efficient possible way for me to change info in the database and for that info to be plugged into an html paragraph and the info being updated every time i change it.
Dave StSomeWhere
19,870 PointsThat's a complex request and will require a bit of work.
You will probably need quite a few courses to accomplish your task.
You should probably check into the beginner html, beginner php, database and web design tracks.
Dave StSomeWhere
19,870 PointsDave StSomeWhere
19,870 PointsPlease show the snippet of markup you'd like as desired output.
You will need to use a server side script like php to get the value from the database and then can update the html doc from javascript or the server side script - pros and cons either way.