Jump to content
Fórum Script Brasil
  • 0

Ajuda em Script para Conversão/Migração de Tabelas


rayfcrols
 Share

Question

Já tive um pequeno avanço no Script, estou agora com o pequeno problema com a ordem de gravação dos dados.

 

$result = mysqli_query($conn,"SELECT Id, cod_lanc1, descr_lanc1, ref_lanc1, prov_lanc1, desco_lanc1, cod_lanc2, descr_lanc2, ref_lanc2, prov_lanc2, desco_lanc2, cod_lanc3, descr_lanc3, ref_lanc3, prov_lanc3, desco_lanc3, cod_lanc4, descr_lanc4, ref_lanc4, prov_lanc4, desco_lanc4, cod_lanc5, descr_lanc5, ref_lanc5, prov_lanc5, desco_lanc5, cod_lanc6, descr_lanc6, ref_lanc6, prov_lanc6, desco_lanc6, cod_lanc7, descr_lanc7, ref_lanc7, prov_lanc7, desco_lanc7, cod_lanc8, descr_lanc8, ref_lanc8, prov_lanc8, desco_lanc8, cod_lanc9, descr_lanc9, ref_lanc9, prov_lanc9, desco_lanc9, cod_lanc10, descr_lanc10, ref_lanc10, prov_lanc10, desco_lanc10, cod_lanc11, descr_lanc11, ref_lanc11, prov_lanc11, desco_lanc11, cod_lanc12, descr_lanc12, ref_lanc12, prov_lanc12, desco_lanc12, cod_lanc13, descr_lanc13, ref_lanc13, prov_lanc13, desco_lanc13, cod_lanc14, descr_lanc14, ref_lanc14, prov_lanc14, desco_lanc14, cod_lanc15, descr_lanc15, ref_lanc15, prov_lanc15, desco_lanc15 FROM producao WHERE cpf = '{cpf}'");
echo $num_results = mysqli_num_rows($result);
			?>
			</br>
			<?
/*
echo "<pre>";
print_r($result);
echo "</pre>";
*/
//$row = mysql_fetch_array($result, MYSQL_ASSOC);
for ($x = 0; $x < $num_results; $x++) {
	$row = mysqli_fetch_assoc($result);
	for ($i = 1; $i <= 11; $i++) {
		
		//if(!is_null($row[0]) || empty($row[0]) || isset($row[0])){
		if(!empty($row["cod_lanc$i"])){
			
		echo $id 			= $row["Id"];				
		echo $cod_lanc 		= $row["cod_lanc$i"];		
		echo $descr_lanc 	= $row["descr_lanc$i"];		
		echo $ref_lanc 		= $row["ref_lanc$i"];		
		echo $prov_lanc 	= $row["prov_lanc$i"];		
		echo $desco_lanc 	= $row["desco_lanc$i"];		
			
		echo "</br>";
		
		mysqli_query($conn2, "INSERT INTO producao_coop (producao_Id,cod_lanc,descr_lanc, ref_lanc, prov_lanc, desco_lanc) VALUES ('".$id."','".$cod_lanc."','".$descr_lanc."','$ref_lanc','".$prov_lanc."','".$desco_lanc."')");
		mysqli_commit($conn2);
		//sc_exec_sql("INSERT INTO producao_coop (producao_Id,cod_lanc,descr_lanc, ref_lanc, prov_lanc, desco_lanc) VALUES ('".$id."','".$cod_lanc."','".$descr_lanc."','$ref_lanc','".$prov_lanc."','".$desco_lanc."')");
			
				}
			}
	//mysqli_close($conn2);
	}

 

Edited by rayfcrols
Script Errado
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

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

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  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.

 Share



  • Forum Statistics

    • Total Topics
      149.6k
    • Total Posts
      646.1k
×
×
  • Create New...