' : '<').'0 and type_seq="'.$TypeSeq.'" and cat="'.$Cat.'" and sub_cat="'.$SubCat.'" order by brewer'; $pref_res=mysqli_query($db, $query); while ($pref_row = mysqli_fetch_assoc($pref_res)) { if (!array_key_exists($pref_row['brewer'], $Prefs)) { $Prefs[$pref_row['brewer']]=array(); } $Prefs[$pref_row['brewer']][]=$pref_row['rank']; } foreach ($Prefs as $Brewer => $Ranks) { foreach ($Ranks as $Rank) { $ChgId=$Brewer.':'.$Rank; $query='select * from style_prefs where brewer="'.$Brewer.'" and rank="'.$Rank.'"'; $pref_res=mysqli_query($db, $query); $pref_row=mysqli_fetch_assoc($pref_res); $query='delete from style_prefs where brewer="'.$Brewer.'" and rank="'.$Rank.'"'; if (mysqli_query($db, $query)) { $query='insert into changelog values(null, null, "'.$Key.'", "style_prefs", "C", "cat", "'.$ChgId.'", "'.$prefs_row['type_seq'].':'.$pref_row['cat'].':'.$pref_row['sub_cat'].'", "")'; mysqli_query($db, $query); $query='insert into changelog values(null, null, "'.$Key.'", "style_prefs", "D", "", "'.$ChgId.'", "", "")'; mysqli_query($db, $query); } } if ($Likes) { $Ranks=array(2, 1, 2, 1); $RankOffset=1; } else { $Ranks=array(-2, -1, -2, -1); $RankOffset=-1; } foreach ($Ranks as $Rank) { $query='select count(*) from style_prefs where brewer="'.$Brewer.'" and rank="'.$Rank.'"'; $cnt_res=mysqli_query($db, $query); $cnt_row=mysqli_fetch_row($cnt_res); if ($cnt_row[0] == 0) { $ToRank=$Rank + $RankOffset; $query='select count(*) from style_prefs where brewer="'.$Brewer.'" and rank="'.$ToRank.'"'; $cnt_res=mysqli_query($db, $query); $cnt_row=mysqli_fetch_row($cnt_res); if ($cnt_row[0] != 0) { $query='update style_prefs set rank="'.$Rank.'" where brewer="'.$Brewer.'" and rank="'.$ToRank.'"'; if (mysqli_query($db, $query)) { $query='insert into changelog values(null, null, "'.$Key.'", "style_prefs", "C", "rank", "'.$Brewer.':'.$ToRank.'", "'.$ToRank.'", "'.$Rank.'")'; mysqli_query($db, $query); } } } } } } // RemPrefs ($TypeSeq, $Cat, $SubCat, TRUE); RemPrefs ($TypeSeq, $Cat, $SubCat, FALSE); $query='select * from style_sub where sg="'.$Comp_SG.'" and type_seq="'.$TypeSeq.'" and cat="'.$Cat.'" and sub_cat="'.$SubCat.'"'; $subcat_res=mysqli_query($db, $query); $subcat_row=mysqli_fetch_assoc($subcat_res); $query='delete from style_sub where sg="'.$Comp_SG.'" and type_seq="'.$TypeSeq.'" and cat="'.$Cat.'" and sub_cat="'.$SubCat.'"'; if (mysqli_query($db, $query)) { $ChgId=$Comp_SG.':'.$TypeSeq.':'.$Cat.':'.$SubCat; foreach ($Map as $row) { $query='insert into changelog values(null, null, "'.$Key.'", "style_sub", "C", "'.$row.'", "'.$ChgId.'", "'.$subcat_row[$row].'", "")'; mysqli_query($db, $query); } $query='insert into changelog values(null, null, "'.$Key.'", "style_sub", "C", "add_ts", "'.$ChgId.'", "'.$subcat_row['add_ts'].'", "")'; mysqli_query($db, $query); $query='insert into changelog values(null, null, "'.$Key.'", "style_sub", "D", "", "'.$ChgId.'", "", "")'; mysqli_query($db, $query); } if (cntSubCat($TypeSeq, $Cat) == 0) { if ($CatType == 'B') { $SweetCarb='N", "N'; } else { if ($Comp_SG == '2015') { $SweetCarb=($CatType == 'C' ? 'I", "D' : 'H", "D'); } else { $SweetCarb='8", "7'; } } $query='insert into style_sub values(null, "'.$Comp_SG.'", "'.$TypeSeq.'", "'.$Cat.'", "", "'.$CatDesc.'", "0", "N", "N", '; $query.='"'.($CatType == 'M' ? 'Y' : 'N').'", '; $query.='"'.$SweetCarb.'", "N", now())'; if (!mysqli_query($db, $query)) { $CleanUp=FALSE; } else { $query='insert into changelog values(null, null, "'.$Key.'", "style_sub", "A", "", "'.$Comp_SG.':'.$TypeSeq.':'.$Cat.':", "", "")'; mysqli_query($db, $query); } } ?>

'.$SubCatDesc."\n"; ?>