Jump to content

[SOLVED] Value added to DB twice?


garethhall

Recommended Posts

Hi guys I have an insert into query for my DB but for some reason when it runs it enters the values twice for

 

$addTradeAndTechnicalName

$addTradeAndTechnicalEmailAddress

so I get a duplicate in my table

 

Can anyone tell me why?

 

Look at the last if statement Thanks Guys :)

 

G

 

<?php 
if($_GET[pageName] == "currentJobs"){
do {  
	$radioBtnName = $_POST[TradeAndTechnical.$row_TradeAndTechnical[id]];
	$sendTo = $_POST[sendTo.TradeAndTechnical.$row_TradeAndTechnical[id]];
	$query_TradeAndTechnical_alter = "update `Trade and Technical` set active='$radioBtnName', emailTo='$sendTo' WHERE id = '$row_TradeAndTechnical[id]'";
	$result_TradeAndTechnical_alter = mysql_query($query_TradeAndTechnical_alter);
	mysql_query($query_TradeAndTechnical_alter);
	} while ($row_TradeAndTechnical = mysql_fetch_assoc($TradeAndTechnical));
  
do {
	$radioBtnName = $_POST[Engineering.$row_Engineering[id]];
	$query_Engineering_alter = "update `Engineering` set active='$radioBtnName' WHERE id = '$row_Engineering[id]'";
	$result_Engineering_alter = mysql_query($query_Engineering_alter);
	mysql_query($query_Engineering_alter);
	} while ($row_Engineering = mysql_fetch_assoc($Engineering));

do {
	$radioBtnName = $_POST[surveying.$row_Surveying[id]];
	$query_Surveying_alter = "update `Surveying` set active='$radioBtnName' WHERE id = '$row_Surveying[id]'";
	$result_Surveying_alter = mysql_query($query_Surveying_alter);
	mysql_query($query_Surveying_alter);
	 } while ($row_Surveying = mysql_fetch_assoc($Surveying));

do {
	$radioBtnName = $_POST[Construction.$row_Construction[id]];
	$query_Construction_alter = "update `Construction` set active='$radioBtnName' WHERE id = '$row_Construction[id]'";
	$result_Construction_alter = mysql_query($query_Construction_alter);
	mysql_query($query_Construction_alter);
	} while ($row_Construction = mysql_fetch_assoc($Construction));

do {
	$radioBtnName = $_POST[Aviation.$row_Aviation[id]];
	$query_Aviation_alter = "update `Aviation` set active='$radioBtnName' WHERE id = '$row_Aviation[id]'";
	$result_Aviation_alter = mysql_query($query_Aviation_alter);
	mysql_query($query_Aviation_alter);
	} while ($row_Aviation = mysql_fetch_assoc($Aviation));

do {
	$radioBtnName = $_POST[HealthAndMedical.$row_HealthAndMedical[id]];
	$query_HealthAndMedical_alter = "update `Health and Medical` set active='$radioBtnName' WHERE id = '$row_HealthAndMedical[id]'";
	$result_HealthAndMedical_alter = mysql_query($query_HealthAndMedical_alter);
	mysql_query($query_EngineeringHealthAndMedical_alter);
	} while ($row_HealthAndMedical = mysql_fetch_assoc($HealthAndMedical)); 

if($_POST[addTradeAndTechnicalName] <>""){
	$query_TradeAndTechnical_add = "insert into `Trade and Technical` (`id`,`jobName`,`active`,`emailTo`) values (Null, '$_POST[addTradeAndTechnicalName]', 'Yes', '$_POST[addTradeAndTechnicalEmailAddress]')";
	$result_TradeAndTechnical_add = mysql_query($query_TradeAndTechnical_add);
	mysql_query($query_TradeAndTechnical_add);
};  	

};

?>

Link to comment
Share on other sites

I dont know if I have an awer to your question, but something i noticed.  I would stay away from tables, stored procedures, and the like with spaces in them.  I always name my tables tbl_x, and my other stuff with appropriate header. The oher thing i noticed is that the syntax you are using for your sql is not breaking the text to allow for the form variable. I understand how your doing it works, but i dont find it easy to read.

 

That and your last two lines look to be causing the problem to me.. Why do you need both lines there. What happends if you leave out "$result_TradeAndTechnical_add = mysql_query($query_TradeAndTechnical_add);"

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.

Guest
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.