Weather forecasts
Posted: 30. June 2009 07:21
Hi,
I'm trying to teach myself a bit about php and SQL so I decided to create a slight variation on a weather forecast block. As the site is for users who are going to travel I wanted them to be able to enter their destination and see the weather there.
You can see what I've got so far at http://www.arvclub.co.uk
Logon newbietest
password letmein
Here's the code for the weather block
And here's the code for the HTML
Any help and advice would be appreciated
Regards
Doug
I'm trying to teach myself a bit about php and SQL so I decided to create a slight variation on a weather forecast block. As the site is for users who are going to travel I wanted them to be able to enter their destination and see the weather there.
You can see what I've got so far at http://www.arvclub.co.uk
Logon newbietest
password letmein
Here's the code for the weather block
Code: Select all
<?php
if (!defined('IN_PHPBB'))
{
exit;
}
if (!defined('IN_PORTAL'))
{
exit;
}
if ($user->data['user_id'] > 1)
{
$display_menu = true;
}
else
{
$display_menu = false;
}
$userid_weather = $user->data['user_id'];
$sql = "SELECT user_from FROM " . phpbb_users . " WHERE user_id = " . $userid_weather;
$result = $db->sql_query_limit($sql, 1);
$weather_location = $db->sql_fetchfield('user_from');
$db-> sql_freeresult($result);
$template->assign_vars(array(
'WEATHER_LOC' => (!empty($weather_location)) ? $weather_location : 'England',
'USERID_WEATHER' => $userid_weather,
'SHOW_SEARCH' => $display_menu,
));
?>
Code: Select all
<div class="portal-panel">
<div class="inner">
<span class="portal-corners-top"><span></span></span>
<h3><img src="{T_THEME_PATH}/images/portal/bullet.gif" width="18px" height="17px" alt=""/> Weather</h3>
<!-- IF SHOW_SEARCH -->
<form method="post" id="forecast" action="{U_UPDATE_LOCATION}">
<input type="text"
tabindex="6"
name="location"
id="searchfield"
size="22"
maxlength="40"
title="Enter town or postcode"
class="inputbox search"
value="{WEATHER_LOC}"
onclick="if(this.value=='Weather')this.value='{WEATHER_LOC}';"
onblur="if(this.value=='')this.value='London';"
/>
<fieldset class="submit-buttons">
<input type="reset"
value="{L_RESET}"
name="reset"
class="button2" />
<input type="submit"
name="action"
value="{L_SUBMIT}"
class="button1" />{S_FORM_TOKEN}
</fieldset>
</form></p><!-- ENDIF -->
<!-Weather in {WEATHER_LOC}, England on your site - HTML code - weatherforecastmap.com --><div align="center"><script src="http://www.weatherforecastmap.com/weather3.php?zona=england_{WEATHER_LOC}"></script><a alt="Weather Today in {WEATHER_LOC}" title="Weather Today in {WEATHER_LOC}" href="http://www.weatherforecastmap.com/england/{WEATHER_LOC}" >Weather Today in {WEATHER_LOC}</a></div><!-end of code--> <span class="portal-corners-bottom"><span></span></span>
</div>
</div>
<br style="clear:both" />
Regards
Doug