I am building a form that allows a business to enter at most 2 mailing addresses. i have the form set up so both inputs are there, storing as a post array. the problem is, when i try to use php to enter the data into in the mysql database, it enters empty data even when a field is null.
html
Expand|Select|Wrap|Line Numbers
- <form method='POST' action='entry2.php' name='entry'>
- <table>
- <tr><td colspan='4' align='center'>Mailing Address</td></tr>
- <tr><td>Street:<input type='text' name='mStreet[]' /></td><td>Zip:
- <?php
- selectDistinct($connection,'CityCode','zip','mzip[]','97465');
- ?>
- </td></tr>
- <tr><td>Street:<input type='text' name='mStreet[]' /></td><td>Zip:
- <?php
- selectDistinct($connection,'CityCode','zip','mzip[]','97465');
- ?>
- </td></tr></table></form>
Expand|Select|Wrap|Line Numbers
- if(!empty($mStreet)){
- for($i=0;$i<2;$i++){
- $Cityquery = "SELECT cityCode FROM CityCode WHERE zip='{$mzip[$i]}'";
- if(!($result = @ mysql_query($Cityquery,$connection))){showerror();}
- $row = mysql_fetch_array($result);
- $mcityCode[$i] = $row['cityCode'];
- $insertQuery = "INSERT INTO Address VALUES(NULL,1,'{$BID}','{$mStreet[$i]}','{$mcityCode[$i]}')";
- if(!(@ mysql_query($insertQuery, $connection))){showerror();}
- }
- }