On line 109 of the scripts.js distro is the TODO


(Using parenthesis instead of carrots to make this read correctly)

I cannot for the life of me figure out how to have the $places array appear in this todo. I've run some tests on my SQL queries and they are working correctly so that if you leave TODO in that code it will appear as a suggestion in the mashup page.

I guess my question is how do you include a php variable in _.template?

I tried using the <% ... %> (as the documentation seems to suggest) to get the variable to appear but it doesn't seem to work.

How do I get $places to appear in _.template?!

1 Answer 1


I figured it out. <%= ... %> is indeed the way you pass in arguments to _.template. When I watched the video in the problem set again the prof mentioned how this code operates similarly to the "%i" placeholder in printf in C.

Essentially, you insert the column titles in your phpMyAdmin table into the <%= ... %> placeholder within the _.template TODO mentioned in the question. So if you wrote your query in search.php to seek city names from $_GET and inserted <%= place_name %> into the _.template TODO in scripts.js then the drop down will now include all instances in which that name appears.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .