jaxdevil Posted October 30, 2008 Share Posted October 30, 2008 I have a form that posts data and some of the form fields are empty and some are not, depending on the usage at the time, so I need to be able to start numbering new lines based on the last line used, so I am trying to set a variable called $x_factor to whatever number is the first on that is NOT sent with the form. Anyone see what I am doing wrong? if(empty($model_number_1)): $x_factor='1'; elseif(empty($model_number_2)): $x_factor='2'; elseif(empty($model_number_3)): $x_factor='3'; elseif(empty($model_number_4)): $x_factor='4'; elseif(empty($model_number_5)): $x_factor='5'; elseif(empty($model_number_6)): $x_factor='6'; elseif(empty($model_number_7)): $x_factor='7'; elseif(empty($model_number_): $x_factor='8'; elseif(empty($model_number_9)): $x_factor='9'; elseif(empty($model_number_10)): $x_factor='10'; elseif(empty($model_number_11)): $x_factor='11'; elseif(empty($model_number_12)): $x_factor='12'; elseif(empty($model_number_13)): $x_factor='13'; elseif(empty($model_number_14)): $x_factor='14'; elseif(empty($model_number_15)): $x_factor='15'; elseif(empty($model_number_16)): $x_factor='16'; elseif(empty($model_number_17)): $x_factor='17'; elseif(empty($model_number_18)): $x_factor='18'; elseif(empty($model_number_19)): $x_factor='19'; elseif(empty($model_number_20)): $x_factor='20'; elseif(empty($model_number_21)): $x_factor='21'; elseif(empty($model_number_22)): $x_factor='22'; elseif(empty($model_number_23)): $x_factor='23'; elseif(empty($model_number_24)): $x_factor='24'; elseif(empty($model_number_25)): $x_factor='25'; elseif(empty($model_number_26)): $x_factor='26'; elseif(empty($model_number_27)): $x_factor='27'; elseif(empty($model_number_28)): $x_factor='28'; elseif(empty($model_number_29)): $x_factor='29'; elseif(empty($model_number_30)): $x_factor='30'; elseif(empty($model_number_31)): $x_factor='31'; elseif(empty($model_number_32)): $x_factor='32'; elseif(empty($model_number_33)): $x_factor='33'; elseif(empty($model_number_34)): $x_factor='34'; elseif(empty($model_number_35)): $x_factor='35'; elseif(empty($model_number_36)): $x_factor='36'; elseif(empty($model_number_37)): $x_factor='37'; elseif(empty($model_number_38)): $x_factor='38'; elseif(empty($model_number_39)): $x_factor='39'; elseif(empty($model_number_40)): $x_factor='40'; else: $x_factor='666'; Quote Link to comment https://forums.phpfreaks.com/topic/130779-solved-determining-if-a-variable-is-missing-and-setting-a-new-variable/ Share on other sites More sharing options...
jaxdevil Posted October 30, 2008 Author Share Posted October 30, 2008 I figured it out.. if(empty($model_number_1)) {$x_factor='1';} elseif(empty($model_number_2)) { $x_factor='2';} elseif(empty($model_number_3)) { $x_factor='3';} elseif(empty($model_number_4)) { $x_factor='4';} elseif(empty($model_number_5)) { $x_factor='5';} elseif(empty($model_number_6)) { $x_factor='6';} elseif(empty($model_number_7)) { $x_factor='7';} elseif(empty($model_number_) { $x_factor='8';} elseif(empty($model_number_9)) { $x_factor='9';} elseif(empty($model_number_10)) { $x_factor='10';} elseif(empty($model_number_11)) { $x_factor='11';} elseif(empty($model_number_12)) { $x_factor='12';} elseif(empty($model_number_13)) { $x_factor='13';} elseif(empty($model_number_14)) { $x_factor='14';} elseif(empty($model_number_15)) { $x_factor='15';} elseif(empty($model_number_16)) { $x_factor='16';} elseif(empty($model_number_17)) { $x_factor='17';} elseif(empty($model_number_18)) { $x_factor='18';} elseif(empty($model_number_19)) { $x_factor='19';} elseif(empty($model_number_20)) { $x_factor='20';} elseif(empty($model_number_21)) { $x_factor='21';} elseif(empty($model_number_22)) { $x_factor='22';} elseif(empty($model_number_23)) { $x_factor='23';} elseif(empty($model_number_24)) { $x_factor='24';} elseif(empty($model_number_25)) { $x_factor='25';} elseif(empty($model_number_26)) { $x_factor='26';} elseif(empty($model_number_27)) { $x_factor='27';} elseif(empty($model_number_28)) { $x_factor='28';} elseif(empty($model_number_29)) { $x_factor='29';} elseif(empty($model_number_30)) { $x_factor='30';} elseif(empty($model_number_31)) { $x_factor='31';} elseif(empty($model_number_32)) { $x_factor='32';} elseif(empty($model_number_33)) { $x_factor='33';} elseif(empty($model_number_34)) { $x_factor='34';} elseif(empty($model_number_35)) { $x_factor='35';} elseif(empty($model_number_36)) { $x_factor='36';} elseif(empty($model_number_37)) { $x_factor='37';} elseif(empty($model_number_38)) { $x_factor='38';} elseif(empty($model_number_39)) { $x_factor='39';} elseif(empty($model_number_40)) { $x_factor='40';} else { $x_factor="666";} Quote Link to comment https://forums.phpfreaks.com/topic/130779-solved-determining-if-a-variable-is-missing-and-setting-a-new-variable/#findComment-678746 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.