Jump to content

Posted Info Not Updating


Hooch
 Share

Recommended Posts

Hey all. I have a weird one this time. All I want is the option to change the year. Check out my code. No matter what it always enters 2009

<?PHP		include 'config.php';		$tbl_1	 = 'tch_three_horse';		$timestamp = time(); 		$year	  = date("Y",$timestamp);		//////////////////////////////////////////////////////////////		//						  Edit Artist					 //		//														  //		//////////////////////////////////////////////////////////////				if(isset($_GET['edit_artist']) || isset($_POST['edit_artist']))		{			if(!$_POST['edit_artist'])			{				$query = mysql_query("SELECT * FROM `" . $tbl_1 . "` WHERE `id` = " . $_GET['edit_artist'] . "") or die(mysql_error());				$r	 = mysql_fetch_array($query);				echo '<form method="POST">';				echo '<input type="hidden" name="id" value="' . $r['id'] . '">';				echo '<div class="left_box_200">Year</div>';				echo '<div class="right_box">  ';				echo '<select name="tour_year" >';				echo '<option selected="selected" value="' . $r['tour_year'] . '">' . $r['tour_year'] . '</option>';				echo '<option value="' . $year . '">' . $year . '</option>';				echo '<option value="' . $year++ . '">' . $year++ . '</option>';				echo '</select>';				echo '</div>';				echo '<hr>';				echo '<div class="left_box_200"> </div>';				echo '<div class="right_box">  <input type="submit" name="edit_artist" value="Submit" ></div>';				echo '</form>';						}				elseif($_POST['edit_artist'])			{				include 'clean_entry.php';				$id		= $_POST['id'];//Hidden field, no need to clean				$tour_year = $_POST['tour_year'];//Drop Down, no need to clean								$update = mysql_query("UPDATE `" . $tbl_1 . "` SET `tour_year` = '$tour_year' WHERE `id` = '$id'") or die(mysql_error());											if($update)				{					echo 'DB update successfull!<br />'				}						}		}?>

This code is for the edit, but even a new entry does not reflect the 2010 selection.Hmm...Thank you for your time

Link to comment
Share on other sites

That's becuase ++ is the postincrement operator, in other words it adds one to the year after returning the current value - therefore your code is actually echoing <option value="2009">2010</option>. You probably just want to use $year + 1 in this case.

$a = 1;echo $a; //echos 1echo $a + 1; //echos 1; $a == 1echo $a++; //echos 1; $a == 2echo $a++; //echos 2; $a == 3echo $a; //echos 3

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...