Jump to content

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

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.