perficut Posted December 23, 2006 Share Posted December 23, 2006 First let me apologise for such a basic command, but I need a little help with the syntax.I have a number of variables passed into the php file from a form. I want to check and see if var#1 is left blank, if so leave var#2 alone. If not then var#2 has the same data as var#1Ex:if Var#1 = " " then nothing happenselse if Var#1 has data, then Var#2 is now = Var#1Var#2 is a persons home addressVar#1 is a persons billing addressThere is always data in Var#2, thier home address, but if the billing address has filled out, then I want the Var containing their home address to now be their billing address. If any of this makes sense. - Heck, I'm confused if I dont think slow about it. But this is probably an easy remedy.THANKS Quote Link to comment Share on other sites More sharing options...
utexas_pjm Posted December 23, 2006 Share Posted December 23, 2006 You might find this syntax useful[code]$foo = (isset($_REQUEST['new_foo']) ? $_REQUEST['new_foo'] : $foo);[/code] Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted December 23, 2006 Share Posted December 23, 2006 [code]<?phpif ($data == ""){echo "";}if ($data != ""){$data2 = $data;}?>[/code]Ted.Is this what you are looking for? or its somthing else? Quote Link to comment Share on other sites More sharing options...
kamasheto Posted December 23, 2006 Share Posted December 23, 2006 [code]<?php// the action='' value in your html form leads to here// assuming the name of the input where your home address goes is called home_address$home_address = $_POST['home_address'];// assuming same as above but billing address is called billing_address$billing_address = $_POST['billing_address'];// now let's checkif(strlen($billing_address)){$home_address = $billing_address;} else {// don't do anything, thanks}// continue our processing// let me make this clear, if someone enters a blank space in the billing address, you'll have virtually a string in both variables// but literally, nothing in both?>[/code] Quote Link to comment Share on other sites More sharing options...
perficut Posted December 24, 2006 Author Share Posted December 24, 2006 thanks guys thats what I needed. Works great now.One final thing, when echoing data, how can do set the font/color of the echoed information.<?php echo $BusinessName; ?> Quote Link to comment Share on other sites More sharing options...
kamasheto Posted December 24, 2006 Share Posted December 24, 2006 [code]<?php echo "<font style='color:red'>" . $BusinessName . "</font>"; ?>[/code] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 24, 2006 Share Posted December 24, 2006 This is a CSS question,[code]<?phpecho "<span style='color:red'>" . $BusinessName . "</span>";?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.