我需要从表中提取3个值并将其分配给一个变量
每个值都基于列,类型和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'];我知道我这样做很难,但无法弄清楚如何执行foreach或while循环来获得所需的结果。