naseerz Posted October 20, 2008 Share Posted October 20, 2008 Hi everyone, I am a newbie working on a php script which basically posts data to a server & was wondering how can i set the script map the value of "housingpayment" $itempost['monthlyhomepayment'] = $item['housingpayment']; Somethis like this. If "housingpayment" =>500 & <1000 set "housingpayment" = 750 If "housingpayment" =>1001 & <1500 set "housingpayment" = 1250 If "housingpayment" =>1501 & set "housingpayment" = 1750 Thanks Naseer Link to comment https://forums.phpfreaks.com/topic/129304-php-field-value-mapping/ Share on other sites More sharing options...
sKunKbad Posted October 24, 2008 Share Posted October 24, 2008 If "housingpayment" =>500 & <1000 set "housingpayment" = 750 If "housingpayment" =>1001 & <1500 set "housingpayment" = 1250 If "housingpayment" =>1501 & set "housingpayment" = 1750 Where did you get this? I think you need a basic lesson in php before trying to attempt anything. What you are specifically seeking to do is a basic if statement using else if and else. Try w3schools.com Link to comment https://forums.phpfreaks.com/topic/129304-php-field-value-mapping/#findComment-673476 Share on other sites More sharing options...
ToonMariner Posted October 25, 2008 Share Posted October 25, 2008 try this... <?php $tvar = &$item['housingpayment']; // temp var with short name just for reuse in switch pass by reference to auto update.... switch(true) { case $tvar < 500: // minimun value not met $tvar = 'ERROR'; break; case $tvar < 1000: $tvar = 750; break; case $tvar < 1500: $tvar = 1250; break; default: $tvar = 1750; break; } echo $item['housingpayment']; ?> Link to comment https://forums.phpfreaks.com/topic/129304-php-field-value-mapping/#findComment-674298 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.