Ok I coded this in a really bad way, so if anyone can give me some suggestions on the right way to do it, that would be awesome. After the form submits, it runs to querys. One to enter data into the database. Two to delete the ones that have a empty field. Reason for the deleting is that a user will have the option to enter multiple store numbers, say the have 50 stores, they only want to enter the contact info once and then have a form to fill out all store numbers attached to it. Well if they don't fill all the store number fields, it is entering the contact info with no store number. So I just delete it.
I know there should be some way to put a while loop or something around it rather then what I got, but evertime I try one it gets stuck in a endless loop. Any suggestions would be great. Thanks in advance.
//form variables
$first_name = $_REQUEST['first_name'];
$last_name = $_REQUEST['last_name'];
$contact_email = $_REQUEST['contact_email'];
$contact_phone = $_REQUEST['contact_phone'];
$acct_number = $_REQUEST['acct_number'];
$quantity = $_REQUEST['quantity'];
$store_name = $_REQUEST['store_name'];
$store_number = $_REQUEST['store_number'];
$address1 = $_REQUEST['address1'];
$address2 = $_REQUEST['address2'];
$city = $_REQUEST['city'];
$state = $_REQUEST['state'];
$zip = $_REQUEST['zip'];
$page_2 = $_REQUEST['page_5'];
$page_5 = $_REQUEST['page_5'];
$page_6_7 = $_REQUEST['page_6_7'];
$page_12 = $_REQUEST['page_12'];
$page_13 = $_REQUEST['page_13'];
$page_14 = $_REQUEST['page_14'];
$cust_incent = $_REQUEST['cust_incent'];
$pages = $_REQUEST['pages'];
$date = date("F j, Y");
$time = date("g:i a");
//connect to databse
$dbname="orders";
$numero= mssql_connect("whatever.com" , "username" , "password" ) or die( "Unable to select database");
//insert query to put data into the table
foreach ($_REQUEST['store_number'] as $key=>$value) {
mssql_query ("INSERT INTO orders (first_name, last_name, contact_email, contact_phone, acct_number, quantity, store_name, store_number, address1, address2, city, state, zip, page_2, page_5, page_6_7, page_12, page_13, page_14, cust_incent, pages, date, time) VALUES ('$first_name', '$last_name', '$contact_email', '$contact_phone', '$acct_number', '$quantity', '$store_name', '$value', '$address1', '$address2', '$city', '$state', '$zip', '$page_2', '$page_5', '$page_6_7', '$page_12', '$page_13', '$page_14', '$cust_incent', '$pages', '$date', '$time')") or die( "Unable to insert into database");
}
mssql_query ("DELETE FROM orders WHERE (store_number = '')");