Idea is when a customer is linked to a company he/she receives a reductionrate on the price of a product: $price * $reductionRate = $endPrice.
I had the idea to make a switch loop where it is checked which company a customer is linked to and returns the reductionrate to later calculate with. Now I want to select from dbase and loop cases in the switch loop. Rough example to get the idea:
switch ($companyname) {
case 'google':
$reductionrate = 0.9;
break;
//companynames and reductionrates are stored in a database and want to loop them inside this switch
//is this possible in anyway? similar like this:
while($row = $result->fetch_assoc()) {
echo("case '$result['companyname']: ' ");
echo("$reductionrate = $result['reductionrate']")
echo("break;");
}
}
return $reductionrate;
Would love to hear if this principle is possible