Page 1 of 1

Using Field Data in Query

Posted: Sun Nov 27, 2005 3:43 pm
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

Re: Using Field Data in Query

Posted: Sun Nov 27, 2005 5:03 pm
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;