Jump to content

[SOLVED] PHP HELP


neverett

Recommended Posts

Hi all.  I'd appreciate any help in advance.  I've included some code of an insert function.  What I'm trying to do is insert fields into my table row (done with the insert function).  I have a $submit_date as well and I want to update it b/c I intentionally left it blank in the $sql = "..." (it would normally come after $eval).  Thus it shouldn't have a value.  So I'm trying to update the $submit_date value in the same row that was just inserted.  So basically I'm updating the row that was just inserted in $sql="...".  But when I run the function without the WHERE o_id = '$o_id'" it updates every $submit_date value.  I thought the code below would work, but it apparently doesn't know the value for $o_id (which is inserted as a NULL b/c it's incremented automatically in the table itself).  Please let me know if there is anyway to gather the value of $o_id (which is inserted as a NULL but assigned a number in the table) and then apply the WHERE o_id = '$o_id' to the update.  The reason I'm doing this is b/c the server we are using is hosted on the West Coast (Pacific Time) and I'm wanting to change the time to Eastern Time.  This is the only way I could think of to change the time zones without having to change something every time the daylight savings time begins or ends.  Please email me at nic.everett@gmail.com for any ideas or reply to this post please!  Thanks for all of your help!

 

// insert an OTM
	function insert(){
		$s_id = $this->s_id;
		$school = $this->school;
		$population = $this->population;
		$region = $this->region;
		$nom_name = $this->nom_name;
		$nom_address = $this->nom_address;
		$nom_email = $this->nom_email;
		$prog_title = $this->prog_title;
		$prog_date = $this->prog_date;
		$target_pop = $this->target_pop;
		$attendance = $this->attendance;
		$time_to_org = $this->time_to_org;
		$people_to_org = $this->people_to_org;
		$cost = $this->cost;
		$prog_desc = $this->prog_desc;
		$prog_goals = $this->prog_goals;
		$publicity = $this->publicity;
		$rl_goals = $this->rl_goals;
		$goal = $this->goal;
		$outcome = $this->outcome;
		$effects = $this->effects;
		$eval = $this->eval;
		$sql = "insert into otms values('NULL', '$s_id', '$school', '$population', '$region', '$nom_name', '$nom_address', '$nom_email', '$prog_title', '$prog_date', '$target_pop', '$attendance', '$time_to_org', '$people_to_org', '$cost', '$prog_desc', '$prog_goals', '$publicity', '$rl_goals', '$goal', '$outcome', '$effects', '$eval')";
		$result = mysql_query($sql);
		$result = mysql_query("UPDATE otms SET submit_date = FROM_UNIXTIME(UNIX_TIMESTAMP()+10800) WHERE o_id = '$o_id'");
		return $result;
	}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.