Jump to content

Desperate for some help!


Recommended Posts

Hi Guys, I have a form i'm trying to use to submit data to 2 seperate tables and i keep getting errors and i have no idea why as i have only slightly modified the query from another one i have used succesfully, if someone can take a look at it for me and let me know what im missing it would be a huge help.


// Make the query.
	$query = "INSERT INTO rma (rma_id, date, store_company, city, address, address2, state_prov, zip_postal, country, phone, ext, contact) VALUES ('$ri', '$dt', '$co', '$ct' , '$ad', '$ad2', '$sp', '$zp', '$cou', '$ph', '$ex', '$cn')";
	$result = @mysql_query ($query); // Run the query.
	$rma_id = mysql_insert_id();

	$result = @mysql_query ($query); // Run the query.
	foreach($_POST as $key => $value)
	//looping through all posted fields
	if(strpos($key, 'item_') !== false)
		//found a part field, need to find out the _x number, then insert the entire row
		$suffix = substr($key, -1); //this gets the _x number
		$item = $_POST['item_' . $suffix];
		$description = $_POST['description_' . $suffix];
		$qty = $_POST['qty_' . $suffix];
		$serial = $_POST['serial_' . $suffix];
		$mfg = $_POST['mfg_' . $suffix];
		$tariff = $_POST['tariff_' . $suffix];
		$value = $_POST['value_' . $suffix];

		$query = "INSERT INTO rma_parts (id, item, description, qty, serial, mfg, tariff, value, rma_id) VALUES ('', '$item', '$description', '$qty', '$serial', '$mfg', '$tariff', 'value', '$rma_id')";
		$result = mysql_query($query);
	if ($result) { // If it ran OK.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.