troubleshooting Question

Trouble inserting data in mysql using php and ajax.

Avatar of IvetteM
IvetteM asked on
PHPMySQL Server
9 Comments1 Solution738 ViewsLast Modified:
I`ve created a form where i draw checkboxes of days and checkboxes of months. The idea is to asign those days lets say monday, tuesday, and friday for the months january, march, and december. I use a if condition to verify if monday has been checked and then another if to checked the months. But when i verify the database it only inserts the monday, tuesday and friday just for january and not for the other 2 months.

Here is part of my code, i've only attach the part where it receives the posts.  Any help is appreciated.

 
$corte=substr($_POST['idmed'] ,-4, strlen($_POST['idmed'] )-0);
	$fechareg = date("Y-m-d h:i:s");
	
		if($con->conectar()==true){
		
	if ($_POST['chkm']=="true"){
		
			if($_POST['chken']=="true"){//January
				$query_Insert= "INSERT INTO cit_distribucion (codigo,iddistribucionmed,idtipocon,idrangohoras,idempleado,primera,subsecuente,mes,yrs,dia,IdUsuarioReg,FechaHoraReg) VALUES ('0',concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',1,'".$_POST['txtyr']."',2,'0','$fechareg')";
				$query = @mysql_query($query_Insert) or die('La consulta falloó: ' . @mysql_error());
			}
			
			if($_POST['chkfb']=="true"){//February
				$query_Insert= "INSERT INTO cit_distribucion (codigo,iddistribucionmed,idtipocon,idrangohoras,idempleado,primera,subsecuente,mes,yrs,dia,IdUsuarioReg,FechaHoraReg) VALUES ('0',concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',2,'".$_POST['txtyr']."',2,'0','$fechareg')";
				$query = @mysql_query($query_Insert) or die('La consulta falloó: ' . @mysql_error());
			}
			if($_POST['chkmz']=="true"){//March
				$query_Insert= "INSERT INTO cit_distribucion (codigo,iddistribucionmed,idtipocon,idrangohoras,idempleado,primera,subsecuente,mes,yrs,dia,IdUsuarioReg,FechaHoraReg) VALUES ('0',concat('L','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',3,'".$_POST['txtyr']."',2,'0','$fechareg')";
				$query = @mysql_query($query_Insert) or die('La consulta falloó: ' . @mysql_error());
			}
	
	}//End of the if for Monday
				
if ($_POST['chkt']=="true"){//Ini for Tuesday
				
		if($_POST['chken']=="true"){//January
				$query_Insert= "INSERT INTO cit_distribucion (codigo,iddistribucionmed,idtipocon,idrangohoras,idempleado,primera,subsecuente,mes,yrs,dia,IdUsuarioReg,FechaHoraReg) VALUES ('0',concat('M','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',1,'".$_POST['txtyr']."',3,'0','$fechareg')";
				$query = @mysql_query($query_Insert) or die('La consulta falloó: ' . @mysql_error());
			}	
			if($_POST['chkfb']=="true"){//February
				$query_Insert= "INSERT INTO cit_distribucion (codigo,iddistribucionmed,idtipocon,idrangohoras,idempleado,primera,subsecuente,mes,yrs,dia,IdUsuarioReg,FechaHoraReg) VALUES ('0',concat('M','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',2,'".$_POST['txtyr']."',3,'0','$fechareg')";
				$query = @mysql_query($query_Insert) or die('La consulta falloó: ' . @mysql_error());
			}
			if($_POST['chkmz']=="true"){//March
				$query_Insert= "INSERT INTO cit_distribucion (codigo,iddistribucionmed,idtipocon,idrangohoras,idempleado,primera,subsecuente,mes,yrs,dia,IdUsuarioReg,FechaHoraReg) VALUES ('0',concat('M','$corte'),'EXT','".$_POST['txtrgs']."','".$_POST['idmed']."','".$_POST['cantprim']."','".$_POST['cantsub']."',3,'".$_POST['txtyr']."',3,'0','$fechareg')";
				$query = @mysql_query($query_Insert) or die('La consulta falloó: ' . @mysql_error());
			}
 
	}

Open in new window

ASKER CERTIFIED SOLUTION
jaltd

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros