Jump to content

Php field value mapping


naseerz

Recommended Posts

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

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

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'];

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.