phpbb style timezone changer

  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

Hi,
I got a functions page, that has:

PHP Code: [ Select ]
 
$timezone = array (
 
 
 
'hour' => '3600'
 
 
 
);
 
 
  1.  
  2. $timezone = array (
  3.  
  4.  
  5.  
  6. 'hour' => '3600'
  7.  
  8.  
  9.  
  10. );
  11.  
  12.  


Its similar to above, but i calculated it properly for each hour: ie) +2 hours => '3600 * 2'

Anyway i have now inputted this array in a select form input. A.K.A drop down menu.

I want to create something similar to what phpBB has in the profile section. This is where it has a drop down menu about the times etc. I want to submit that to update a column named 'timezone'.

I have tried the following:

PHP Code: [ Select ]
$update ("UPDATE gs_rethink WHERE timezone = '$POST['newtimezone']'");
 
 
 
 
 
$timezone = $newtimezone
 
 
 
//update the clock
 
echo "<form method=$_POST>";
 
echo "<br>";
 
 
 
echo '<SELECT name=$newtimezone>';
 
foreach ($timezone as $key => $value)
 
{
 
echo '<OPTION value='.$key.'> '.$key.'';
 
}
 
echo '</select>';
 
 
 
echo "<input type=submit value=submit>";
 
 
 
echo "</form>";
  1. $update ("UPDATE gs_rethink WHERE timezone = '$POST['newtimezone']'");
  2.  
  3.  
  4.  
  5.  
  6.  
  7. $timezone = $newtimezone
  8.  
  9.  
  10.  
  11. //update the clock
  12.  
  13. echo "<form method=$_POST>";
  14.  
  15. echo "<br>";
  16.  
  17.  
  18.  
  19. echo '<SELECT name=$newtimezone>';
  20.  
  21. foreach ($timezone as $key => $value)
  22.  
  23. {
  24.  
  25. echo '<OPTION value='.$key.'> '.$key.'';
  26.  
  27. }
  28.  
  29. echo '</select>';
  30.  
  31.  
  32.  
  33. echo "<input type=submit value=submit>";
  34.  
  35.  
  36.  
  37. echo "</form>";


This i have done below a code that gets the current time and the current timezone format.

Anyway, how would i be able to do the above statement correctly?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • vijaya
  • Newbie
  • Newbie
  • vijaya
  • Posts: 7

Post 3+ Months Ago

Hi
Can you give more info
whats the parameter value you are passing for
newtimezone and whats the calculation for 3600 *2 as well
Thanks
Vijaya
  • vijaya
  • Newbie
  • Newbie
  • vijaya
  • Posts: 7

Post 3+ Months Ago

Is this what you want... or have I missed some thing
<?php
$timezone = array (
'hour' => '3600'
);

$update= "UPDATE gs_rethink WHERE timezone = ".$_REQUEST['newtimezone'];
echo $update;

//if you want the $timezone to change change the array accordingly.
//$timezone = $newtimezone ;

//update the clock
echo "<form method=$_POST>";
echo "<br>";

echo '<SELECT name=\"newtimezone\">';
while (list($key, $value) = each ($timezone))
{

echo '<OPTION value='.$key.'> '.$value.'';
}
echo '</select>';

echo "<input type=submit value=submit>";

echo "</form>"; ?>
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

I have a page called functions:

in there is something like this

PHP Code: [ Select ]
 
$timezone = array (
 
'-2 Hours' => '-7200',
 
'-1 Hours' => '-3600',
 
'Normal' => '0',
 
'+1 Hours' => '3600',
 
'+2 Hours' => '7200'
 
);
 
 
  1.  
  2. $timezone = array (
  3.  
  4. '-2 Hours' => '-7200',
  5.  
  6. '-1 Hours' => '-3600',
  7.  
  8. 'Normal' => '0',
  9.  
  10. '+1 Hours' => '3600',
  11.  
  12. '+2 Hours' => '7200'
  13.  
  14. );
  15.  
  16.  


On the page i am on now, i have an include statement to include the page in my script.

Now, I want to be able to change the timezone as well. On my mysql table i have a column called "timezone" which holds the timezone number.

The reason i made an array out of the above is because i wanted to show "+1 hour" etc in a drop down menu.

Whatever shows in the drop down menu is in the functions page (which is included).

Now at the same time i want to be able to update a column.

So in the drop down box, i want whatever is selected to be updated in the timezone column so that when i refresh the page the timezone has changed in the time.

I hope i explained this correctly.
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

here is a preview of what i want:

http://dhost.info/gmforum/rethink/req/test.php

sorry about pop up.
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

no clue?!
  • vijaya
  • Newbie
  • Newbie
  • vijaya
  • Posts: 7

Post 3+ Months Ago

Check , this , Let me know if I have not got it right.
<?php
$timezone = array (
'-2 Hours' => '-7200',
'-1 Hours' => '-3600',
'Normal' => '0',
'+1 Hours' => '3600',
'+2 Hours' => '7200'
);

$update= "UPDATE gs_rethink set timezone = ".$_REQUEST['newtimezone'];
echo $update;

//update the clock
echo "<form method=$_POST>";
echo "
";

echo "<SELECT name='newtimezone'>";
while (list($key, $value) = each ($timezone))
{

echo '<OPTION value='.$value.'> '.$key.'';
}
echo '</select>';

echo "<input type=submit value=submit>";

echo "</form>"; ?>
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

why echo the update?!


action="$PHP_SELF"???

why do a post, then a request? Shouldnt they be same?!
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

PHP Code: [ Select ]
 
if (($_POST['submit'])) {
 
 
 
$timezone = $_POST['newtimezone'];
 
 
 
$sql="UPDATE news SET timezone='$newtimezone' LIMIT=1";
 
 
 
 $sql_result = mysql_query($sql) or die ('Not Updated...');
 
  echo"<TABLE WIDTH=300 ALIGN=center>";
 
  echo"<TR><TD ALIGN=center>Record Updated</TD></TR>";
 
  mysql_close($link);
 
 
 
}
 
else
 
{
 
 
 
echo "<br>";
 
 
 
echo "<form method=$_POST action=$PHP_SELF>";
 
 
 
echo "<SELECT name=newtimezone>";
 
foreach ($timezone as $key => $value)
 
{
 
echo "<OPTION value=$value> $key";
 
}
 
echo '</select>';
 
echo "<input type=submit value=submit>";
 
echo "</form>";
 
 
 
}
 
 
 
 
  1.  
  2. if (($_POST['submit'])) {
  3.  
  4.  
  5.  
  6. $timezone = $_POST['newtimezone'];
  7.  
  8.  
  9.  
  10. $sql="UPDATE news SET timezone='$newtimezone' LIMIT=1";
  11.  
  12.  
  13.  
  14.  $sql_result = mysql_query($sql) or die ('Not Updated...');
  15.  
  16.   echo"<TABLE WIDTH=300 ALIGN=center>";
  17.  
  18.   echo"<TR><TD ALIGN=center>Record Updated</TD></TR>";
  19.  
  20.   mysql_close($link);
  21.  
  22.  
  23.  
  24. }
  25.  
  26. else
  27.  
  28. {
  29.  
  30.  
  31.  
  32. echo "<br>";
  33.  
  34.  
  35.  
  36. echo "<form method=$_POST action=$PHP_SELF>";
  37.  
  38.  
  39.  
  40. echo "<SELECT name=newtimezone>";
  41.  
  42. foreach ($timezone as $key => $value)
  43.  
  44. {
  45.  
  46. echo "<OPTION value=$value> $key";
  47.  
  48. }
  49.  
  50. echo '</select>';
  51.  
  52. echo "<input type=submit value=submit>";
  53.  
  54. echo "</form>";
  55.  
  56.  
  57.  
  58. }
  59.  
  60.  
  61.  
  62.  


this is what i have at the moment.
  • vijaya
  • Newbie
  • Newbie
  • vijaya
  • Posts: 7

Post 3+ Months Ago

<?php
$timezone1 = array (
'-43200' => '-12 Hours',
'-39600' => '-11 Hours',
'-36000' => '-10 Hours',
'-32400' => '-9 Hours',
'-28800' => '-8 Hours',
'-25200' => '-7 Hours',
'-21600' => '-6 Hours',
'-18000' => '-5 Hours',
'-14400' => '-4 Hours',
'-10800' => '-3 Hours',
'-7200' => '-2 Hours',
'-3600' => '-1 Hours',
'0' => 'Normal',
'3600' => '+1 Hours',
'7200' => '+2 Hours',
'10800' => '+3 Hours',
'14400' => '+4 Hours',
'18000' => '+5 Hours',
'21600' => '+6 Hours',
'25200' => '+7 Hours',
'28800' => '+8 Hours',
'32400' => '+9 Hours',
'36000' => '+10 Hours',
'39600' => '+11 Hours',
'43200' => '+12 Hours'

);


$timezone = $_REQUEST['newtimezone'];
if($timezone!="")
{
$sql="UPDATE news SET timezone='$newtimezone' LIMIT=1";
$sql_result = mysql_query($sql) or die ('Not Updated...');
echo"<TABLE WIDTH=300 ALIGN=center>";
echo"<TR><TD ALIGN=center>Record Updated</TD></TR>";
mysql_close($link);
}


echo "<br>";

echo "<form method=POST action=\"postXml.php\">";

echo "<SELECT name=newtimezone>";
foreach ($timezone1 as $key => $value)
{
echo "<OPTION value=$key> $value";
}
echo '</select>';
echo "<input type=submit value=submit>";
echo "</form>";

?>

Post Information

  • Total Posts in this topic: 10 posts
  • Users browsing this forum: No registered users and 88 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.