Hi There,
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
php to save to db
p.s. the selectDistinct functions return a list of zip codes that are accepted, and in the php it is used to determine the code that is associated with the zip
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
Code:
<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>
Code:
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();}
}
}
Comment