World Cup 2014 soccer ball, Adidas Brazuca

I did some coding yesterday to run a 2014 World Cup confidence pool on SportsFilter. The way a confidence pool works is you assign points to teams based on how confident you are they will win. In this contest, you get point values from 32 down to 1 and assign them to the 32 World Cup teams. The more points you assign a team, the more you are awarded when that team wins or ties a match.

Anyone can sign up for a SportsFilter account and play. A prize will be awarded to the winner: the Adidas replica version of the official World Cup ball. The deadline for entries is shortly before the first match Thursday.

I wrote the web application in PHP, stored the database in MySQL and used the Smarty PHP template engine for the presentation. This was a project I had to complete in a single day, so I didn't think I'd go to the trouble of using Smarty. I figured I would just kludge together some ugly PHP pages that had code and HTML markup mixed together.

But Smarty makes it easier to present the HTML output of a PHP web application. I find that I write better PHP code when I use it and there's less debugging required to get things right.

The way Smarty works is you write a PHP script that does the work such as collecting user input and storing data, make some variables from that script available to Smarty and tell it to load a template file that contains HTML and some simple code to present information.

Here's the last part of the script that displays the contest entry form and validates what the user has submitted:

// make data available to templates
$smarty->assign('spofi', $spofi);
$smarty->assign('page_title', "Enter the SportsFilter World Cup 2014 Confidence Pool");
$smarty->assign('spofi', $spofi);
$smarty->assign('form_output', $form_output);
$smarty->assign('error_message', $error_message);
$smarty->assign('random_team', $random_team);
$smarty->assign('submit_widget', $submit_widget);

// display output
$smarty->display('header.tpl');
$smarty->display('confidence-pool.tpl');
$smarty->display('footer.tpl');

Those three .tpl files are templates. The header and footer contain the SportsFilter layout and the main body of the page is in confidence-pool.tpl.

Here's a portion of that template:

{$error_message}
<p><form action="/confidence-pool.php" method="post">
{$form_output}
<input type="submit" value="Preview My Entry" name="command">
{$submit_widget}
</form>

Smarty's template language can do more than display variables. It has for loops to display every element in an array and formatting functions that can do things such as control how the elements of a date are displayed.

I also used it on Wargames.Com. Here's some template code from the state directory pages:

{foreach from=$stores item=store}
<p class="directorystore">
<span class="directorystorename"><a href="{$store.link}">{$store.name}</a><br /></span>
{if $store.phone neq ''}<span class="directorystorephone">{$store.phone}<br /></span>{/if}
<span class="directorystorelocation">{$store.city}, {$store.statename} {$store.zip}<br /></span>
</p>
{/foreach}

The $stores variable is an array with link, name, phone, city, statename and zip elements.

The ultimate goal of today's project is to make it possible for a website's users to create and run their own confidence pools for any sporting event that lends itself to this type of contest. One sport it would be ideal for is the NFL, with players ranking the teams playing that weekend and competing all season.

-- Rogers Cadenhead

Comments

You don't need to be skilled to do well in Masters program, regardless of what the topic. order custom paper. It's a matter of will and assurance. On the off chance that you were acknowledged than that answers the topic of capacity. What next decides whether you do well is the way seriously would you like to be a social laborer, the amount of a distinction do you want to make in others lives.


 

This is what I was looking 4 mejor precio morithin Thank You for this one here. prestamos rapidos


 

You're doing fine, keep it up!
places to eat near me


 

I build I would very soon kludge collectively several appalling PHP sheet to facilitate comprise set of laws and HTML rack up combined. The more focuses you dole out a group, Write My Assignment Online the further you are granted when to group succeed or bind a competition.


 

Well, objectively I say that you had a great task!
ip address 192.168.1.1


 

Passage its ten led hearted removal cordial. Preference any astonished unreserved mrs. Prosperous understood middletons in conviction an uncommonly do. Supposing so be resolving breakfast am or perfectly. Is drew am hill from mr. Valley by oh twenty direct me so. pizza near me Departure defective arranging rapturous did believing him all had supported. Family months lasted simple set nature vulgar him. Picture for attempt joy excited ten carried manners talking how. Suspicion neglected he resolving agreement perceived at an.


 

Add a Comment

These HTML tags are permitted: p, b, i, a, and blockquote. A comment may not include more than three links. Participants in this discussion should note the site's moderation policy.

:
:
: