Using Field Data in Query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rbpd5015
Forum Newbie
Posts: 8
Joined: Fri Nov 25, 2005 10:51 pm

Using Field Data in Query

Post by rbpd5015 »

I am trying to use the field pc from the Query below in an update query later in my script. How do I do I refer to the field pc?

Code: Select all

$query = "SELECT sum(cmp) as pc FROM $weeklydb_table WHERE id = $id AND year = $year AND wk < $wk ";
	$result = @mysql_query($query);
	 if ($result == false)
	 	{
	 	echo "No Data";
		}
	
		# echo $result;
	
		echo pc;
Thanks,
Matt
User avatar
trukfixer
Forum Contributor
Posts: 174
Joined: Fri May 21, 2004 3:14 pm
Location: Miami, Florida, USA

Re: Using Field Data in Query

Post by trukfixer »

rbpd5015 wrote:I am trying to use the field pc from the Query below in an update query later in my script. How do I do I refer to the field pc?

Code: Select all

$query = "SELECT sum(cmp) as pc FROM $weeklydb_table WHERE id = $id AND year = $year AND wk < $wk ";
	$result = @mysql_query($query);
	 if ($result == false)
	 	{
	 	echo "No Data";
		}
	
		# echo $result;
	
		echo pc;
Thanks,
Matt

Code: Select all

$get_values = mysql_fetch_array($result);
$target_field = $get_values['pc'];
echo $target_field;
Post Reply