I need to pull 3 values from a table and assign each one to a variable
each value is based on to columns, a type and an id
$ht_live_query = mysql_query("SELECT htcode FROM coupon WHERE pid='$pid' AND type='L'");
$ht_live_result = mysql_fetch_array($ht_live_query);
$htCODE_Live = $ht_live_result['htcode'];
You can see that I am assigning the desired value to the variable $htL
$ht_General_query = mysql_query("SELECT htcode FROM coupon WHERE pid='$pid' AND type='G'");
$ht_General_result = mysql_fetch_array($ht_General_query);
$htCODE_General = $ht_General_result['htcode'];
$ht_Reward_query = mysql_query("SELECT htcode FROM coupon WHERE pid='$pid' AND type='R'");
$ht_Reward_result = mysql_fetch_array($ht_Reward_query);
$htCODE_Reward = $ht_Reward_result ['htcode'];
I know I am doing this the hard way but can not figure out how to do the foreach or while loop to attain the desired results.
Use an
IN()clause asIN('L','G','R').When fetching results, you can check the value and do something different if necessary.