petroz Posted September 6, 2009 Share Posted September 6, 2009 Hi Guys, Newb here and with php, sql and html... But I am trying. I have a form that includes and address field. Each part of the address (IE. Street, City, State, etc..) is a separate field on the form. I would like to process all the fields of the address into one "address cell" on the mysql db. So I guess I am looking to combine all the fields into $address = $_POST['address']; Any help would be greatly appreciated. Thanks, P Link to comment https://forums.phpfreaks.com/topic/173288-combining-data-from-form-fields/ Share on other sites More sharing options...
kratsg Posted September 6, 2009 Share Posted September 6, 2009 Can you perhaps post the code for the form so we could better help you with this? Link to comment https://forums.phpfreaks.com/topic/173288-combining-data-from-form-fields/#findComment-913434 Share on other sites More sharing options...
petroz Posted September 6, 2009 Author Share Posted September 6, 2009 I cut out most of the countries, but here is everything related to address. Thanks!! <li id="li_5"> <label class="description" for="element_5">Address </label> <div> <input id="element_5_1" name="element_5_1" class="element text large" value="" type="text" /> <label for="element_5_1">Street Address</label> </div> <div> <input id="element_5_2" name="element_5_2" class="element text large" value="" type="text" /> <label for="element_5_2">Address Line 2</label> </div> <div class="left"> <input id="element_5_3" name="element_5_3" class="element text medium" value="" type="text" /> <label for="element_5_3">City</label> </div> <div class="right"> <input id="element_5_4" name="element_5_4" class="element text medium" value="" type="text" /> <label for="element_5_4">State / Province / Region</label> </div> <div class="left"> <input id="element_5_5" name="element_5_5" class="element text medium" maxlength="15" value="" type="text" /> <label for="element_5_5">Postal / Zip Code</label> </div> <div class="right"> <select class="element select medium" id="element_5_6" name="element_5_6"><option value="" selected="selected"></option><option value="Afghanistan">Afghanistan</option</select> <label for="element_5_6">Country</label> </div> </li> Link to comment https://forums.phpfreaks.com/topic/173288-combining-data-from-form-fields/#findComment-913436 Share on other sites More sharing options...
kratsg Posted September 6, 2009 Share Posted September 6, 2009 name="element_5_1" name="element_5_2" name="element_5_3" name="element_5_4" name="element_5_5" name="element_5_6" These are the address form elements. $address = $_POST['element_5_1'] . $_POST['element_5_2'] . $_POST['element_5_3'] . $_POST['element_5_4'] . $_POST['element_5_5'] . $_POST['element_5_6']; Link to comment https://forums.phpfreaks.com/topic/173288-combining-data-from-form-fields/#findComment-913437 Share on other sites More sharing options...
petroz Posted September 6, 2009 Author Share Posted September 6, 2009 Awesome!! Thanks a bunch! Link to comment https://forums.phpfreaks.com/topic/173288-combining-data-from-form-fields/#findComment-913438 Share on other sites More sharing options...
petroz Posted September 6, 2009 Author Share Posted September 6, 2009 Ok, so it should be working, but now I am getting "unexpected T_VARIABLE on line 10" Please let me know where I have gone wrong. Thanks, P <?PHP include 'db.php'; $username = $_GET['user']; $nickname = $_POST['element_1']; $description = $_POST['element_7']; $email = $_POST['element_4']; $phone = $_POST['element_3_1'] . $_POST['element_3_2'] . $_POST['element_3_3']; $address = $_POST['element_5_1'] . $_POST['element_5_2'] . $_POST['element_5_3'] . $_POST['element_5_4'] . $_POST['element_5_5'] . $_POST['element_5_6']; $hours = $_POST['element_6']; Link to comment https://forums.phpfreaks.com/topic/173288-combining-data-from-form-fields/#findComment-913488 Share on other sites More sharing options...
kratsg Posted September 6, 2009 Share Posted September 6, 2009 $phone = $_POST['element_3_1'].$_POST['element_3_2'].$_POST['element_3_3']; $address = $_POST['element_5_1'].$_POST['element_5_2'].$_POST['element_5_3'].$_POST['element_5_4'].$_POST['element_5_5'].$_POST['element_5_6']; Link to comment https://forums.phpfreaks.com/topic/173288-combining-data-from-form-fields/#findComment-913615 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.