Jump to content
Fórum Script Brasil
  • 0

Gravar dados no BD no Grid


Zaque

Question

Pessoal,

Como faço para gravar os dados quando saio de um campo na tabela.

Código abaixo:


<?php
date_default_timezone_set('America/Sao_Paulo');
$data_hoje=date("d/m/Y");
$hora_atual=date("H:i");
$dias_semana = array('Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado');
$dias_semana = $dias_semana[date("w")];


// Se a data tiver sido cadastrada na tela RMDV

If (empty($_POST['Data'])){
$Data_Real = $_GET['DataInc'];}

else {
$Data_Real = $_POST['Data'];
}



//Dia da semana da data da operacao

$mes = substr($Data_Real,3,2);
$ano = substr($Data_Real,6,4);
$dia = substr($Data_Real,0,2);
$Data_Real2 = ($ano."-".$mes."-".$dia);
$Data_Real2 = strtotime($Data_Real2);


$Dia_Data2 = date("w", $Data_Real2);
$Dia_Data2 =($Dia_Data2+1);


echo "_____________=> Operação...: "."<b>".$Data_Real."__________";
echo "<a href=\"RMDV_Data_Real.php?DataInc=$Data_Real\" target=\"_parent\"><img src=\"img/engrenagem.gif\" alt=\"FT\" width=21 height=21 />__Linhas Reais</a>";

require_once("funcoes\conexao.php");


switch ($Dia_Data2) {
case "1":
$rs = mysql_query("select DISTINCT NumdaLinha, Placa, NFicha, NomeRecurso1, HoraPartida, DescricaoModelo, Transportadora, DescrUnidade from FT WHERE Domingo = '01' and DescrUnidade = 'CTO JAGUARE' ORDER BY NumdaLinha");
$row=mysql_fetch_array ($rs);
if ($row == 0)
echo "&lt;script>alert('Nenhum registro encontrado na linha neste dia da semana!'); java script:window.close()</script>";

case "2":
$rs = mysql_query("select DISTINCT NumdaLinha, Placa, NFicha, NomeRecurso1, HoraPartida, DescricaoModelo, Transportadora, DescrUnidade from FT WHERE Domingo = '02' and DescrUnidade = 'CTO JAGUARE' ORDER BY NumdaLinha");
$row=mysql_fetch_array ($rs);
if ($row == 0)
echo "&lt;script>alert('Nenhum registro encontrado na linha neste dia da semana!'); java script:window.close()</script>";



case "3":
$rs = mysql_query("select DISTINCT NumdaLinha, Placa, NFicha, NomeRecurso1, HoraPartida, DescricaoModelo, Transportadora, DescrUnidade from FT WHERE Terca = '03' and DescrUnidade = 'CTO JAGUARE' ORDER BY NumdaLinha");
$row=mysql_fetch_array ($rs);
if ($row == 0)
echo "&lt;script>alert('Nenhum registro encontrado na linha neste dia da semana!'); java script:window.close()</script>";


case "4":
$rs = mysql_query("select DISTINCT NumdaLinha, NomeRecurso1, NFicha, Placa, HoraPartida, DescricaoModelo, Transportadora, DescrUnidade from FT WHERE Quarta = '04' and DescrUnidade = 'CTO JAGUARE' ORDER BY NumdaLinha");
$row=mysql_fetch_array ($rs);
if ($row == 0)
echo "&lt;script>alert('Nenhum registro encontrado na linha neste dia da semana!'); java script:window.close()</script>";


case "5":
$rs = mysql_query("select DISTINCT NumdaLinha, NomeRecurso1, Placa, NFicha, HoraPartida, DescricaoModelo, Transportadora, DescrUnidade from FT WHERE Quinta = '05' and DescrUnidade = 'CTO JAGUARE' ORDER BY HoraPartida");
$row=mysql_fetch_array ($rs);
if ($row == 0)
echo "&lt;script>alert('Nenhum registro encontrado na linha neste dia da semana!'); java script:window.close()</script>";


case "6":
$rs = mysql_query("select DISTINCT NumdaLinha, Placa, NFicha, NomeRecurso1, HoraPartida, DescricaoModelo, Transportadora, DescrUnidade from FT WHERE Sexta = '06' and DescrUnidade = 'CTO JAGUARE' ORDER BY NumdaLinha");
$row=mysql_fetch_array ($rs);
if ($row == 0)
echo "&lt;script>alert('Nenhum registro encontrado na linha neste dia da semana!'); java script:window.close()</script>";



case "7":
$rs = mysql_query("select DISTINCT NumdaLinha, NomeRecurso1, Placa, NFicha, HoraPartida, HoraChegada, DescricaoModelo, Transportadora, DescrUnidade from FT WHERE Sabado = '07' and DescrUnidade = 'CTO JAGUARE' ORDER BY NumdaLinha");
$row=mysql_fetch_array ($rs);
if ($row == 0)
echo "&lt;script>alert('Nenhum registro encontrado na linha neste dia da semana!'); java script:window.close()</script>";



break;

}


echo "<TABLE WIDTH=100% BORDER=2 CELLPADDING=0 CELLSPACING=0 >";

echo "<TR VALIGN=TOP>";
echo "<TD align=center WIDTH=9%>";
echo "<font size=4>";
echo "<font color=blue><b>";
echo "Linha";
echo "<BR>";
echo "</TD>";


echo "<TD align=center WIDTH=5%>";
echo "<font size=4>";
echo "<font color=blue><b>";
echo "Part"."<br>"."Prev" ;
echo "</TD>";


echo "<TD align=center WIDTH=5%>";
echo "<font size=4>";
echo "<font color=blue><b>";
echo "Part"."<br>"."Real" ;
echo "</TD>";



echo "<TD align=center WIDTH=6%>";
echo "<font size=4>";
echo "<font color=blue><b>";
echo "Hod" ;
echo "</TD>";



echo "<TD align=center WIDTH=5%>";
echo "<font size=4>";
echo "<font color=blue><b>";
echo "Cheg"."<br>"."Prev" ;
echo "</TD>";


echo "<TD align=center WIDTH=5%>";
echo "<font size=4>";
echo "<font color=blue><b>";
echo "Cheg"."<br>"."Real" ;
echo "</TD>";



echo "<TD align=center WIDTH=6%>";
echo "<font size=4>";
echo "<font color=blue><b>";
echo "Hod" ;
echo "</TD>";


echo "<TD align=center WIDTH=16%>";
echo "<font size=4>";
echo "<font color=blue><b>";
echo "Transportadora";
echo "<BR>";
echo "<HR>";
echo "Modelo do Veículo";
echo "</TD>";


echo "<TD align=center WIDTH=16%>";
echo "<font size=4>";
echo "<font color=blue><b>";
echo "Veículo Prev";
echo "<BR>";
echo "<HR>";
echo "Motorista Prev";
echo "</TD>";


echo "</TR>";
echo "</TABLE>";


// Tabela com o primeiro registro - Linha

echo "<TABLE WIDTH=100% background=\"blue\" bordercolor=LightGray BORDER=2 CELLPADDING=0 CELLSPACING=0 >";
echo "<TR VALIGN=TOP>";
echo "<TD align=center WIDTH=9%>";
$Linha = $row['NumdaLinha'];
$Recurso = $row['NomeRecurso1'];
$Placa = $row['Placa'];
$NumFicha = $row['NFicha'];
$PartidaPrev = $row['HoraPartida'];

echo "<font size=4>";
echo "<font color=blue>";

echo "$Linha";

echo "<BR>";
echo "</font>";

echo "<a href=\"CadInicio.php?NF=$NumFicha&Linha=$Linha&Data_Real=$Data_Real&Recurso=$Recurso&Placa=$Placa\" target=\"_parent\"><img src=\"sobe.gif\" alt=\"Partida\" width=20 height=20 /></a>";
echo "-";
echo "<a href=\"CadTermino.php?NF=$NumFicha&Linha=$Linha&Data_Real=$Data_Real&Recurso=$Recurso&Placa=$Placa\" target=\"_parent\"><img src=\"desce.gif\" alt=\"Chegada\" width=20 height=20 /></a>";
echo "-";
echo "<a href=\"FT_Visual.php?NF=$NumFicha&Linha=$Linha\" target=\"_parent\"><img src=\"img/ft.gif\" alt=\"FT\" width=20 height=20 /></a>";
echo "-";
echo "<a href=\"RDVO.php?NF=$NumFicha&Linha=$Linha&Dia=$dias_semana\" target=\"_parent\"><img src=\"img/rdvo.jpg\" alt=\"FT\" width=20 height=20 /></a>";
echo "</TD>";



echo "<TD align=center WIDTH=5%>";
echo $row['HoraPartida'];
echo "</TD>";





echo "<TD align=center WIDTH=5%>";
echo "<input type=text MaxLength=5 name=Partida style=text-align:center size=5 onkeypress='valida_horas(this)' />";
echo "</TD>";

echo "<TD align=center WIDTH=6%>";
echo "<input type=text MaxLength=6 name=Hodometro style=text-align:center size=6 onkeypress='return SomenteNumero(event)' />";
echo "</TD>";




echo "<TD align=center WIDTH=5%>";
echo $row['HoraChegada'];
echo "</TD>";


echo "<TD align=center WIDTH=5%>";
echo "<input type=text MaxLength=5 name=Chegada style=text-align:center size=5 onkeypress='valida_horas(this)' />";
echo "</TD>";

echo "<TD align=center WIDTH=6%>";
echo "<input type=text MaxLength=6 name=Hodometro style=text-align:center size=6 onkeypress='return SomenteNumero(event)' />";
echo "</TD>";






echo "<TD WIDTH=16%>";
echo "-".$row['Transportadora'];
echo "<BR>";
echo "<HR>";
echo $row['DescricaoModelo'];
echo "</TD>";


echo "<TD WIDTH=16%>";
echo "-".$row['Placa'];
echo "<BR>";
echo "<HR>";
echo "-".$row['NomeRecurso1'];
echo "</TD>";



echo "</TR>";
echo "</TABLE>";



// Inicio do Loop para preencher a tabela com os dados

while($row=mysql_fetch_array($rs)){



echo "<TABLE WIDTH=100% bordercolor=LightGray BORDER=2 CELLPADDING=0 CELLSPACING=0 >";


echo "<TR VALIGN=TOP>";
echo "<TD align=center WIDTH=9%>";
$Linha = $row['NumdaLinha'];
$Recurso = $row['NomeRecurso1'];
$Placa = $row['Placa'];
echo "<font size=4>";
echo "<font color=blue>";
echo "$Linha";
echo "</font>";


echo "<BR>";
echo "<a href=\"CadInicio.php?NF=$NumFicha&Linha=$Linha&Data_Real=$Data_Real&Recurso=$Recurso&Placa=$Placa\" target=\"_parent\"><img src=\"sobe.gif\" alt=\"Partida\" width=20 height=20 /></a>";
echo "-";
echo "<a href=\"CadTermino.php?NF=$NumFicha&Linha=$Linha&Data_Real=$Data_Real&Recurso=$Recurso&Placa=$Placa\" target=\"_parent\"><img src=\"desce.gif\" alt=\"Chegada\" width=20 height=20 /></a>";
echo "-";
echo "<a href=\"FT_Visual.php?NF=$NumFicha&Linha=$Linha\" target=\"_parent\"><img src=\"img/ft.gif\" alt=\"FT\" width=20 height=20 /></a>";
echo "-";
echo "<a href=\"RDVO.php?NF=$NumFicha&Linha=$Linha&Dia=$dias_semana\" target=\"_parent\"><img src=\"img/rdvo.jpg\" alt=\"FT\" width=20 height=20 /></a>";
echo "</TD>";


echo "<TD align=center WIDTH=5%>";
echo $row['HoraPartida'];
echo "</TD>";


echo "<TD align=center WIDTH=5%>";
echo "<input type=text MaxLength=5 style=text-align:center name=Partida size=5 onkeypress='valida_horas(this)' />";
echo "</TD>";


echo "<TD align=center WIDTH=6%>";
echo "<input type=text MaxLength=6 style=text-align:center name=Hodometro size=6 onkeypress='return SomenteNumero(event)' />";
echo "</TD>";



echo "<TD align=center WIDTH=5%>";
echo $row['HoraChegada'];
echo "</TD>";


echo "<TD align=center WIDTH=5%>";
echo "<input type=text MaxLength=5 style=text-align:center name=Chegada size=5 onkeypress='valida_horas(this)' />";
echo "</TD>";

echo "<TD align=center WIDTH=6%>";
echo "<input type=text MaxLength=6 style=text-align:center name=Hodometro size=6 onkeypress='return SomenteNumero(event)' />";
echo "</TD>";





echo "<TD WIDTH=16%>";
echo "-".$row['Transportadora'];
echo "<BR>";
echo "<HR>";
echo $row['DescricaoModelo'];
echo "</TD>";


echo "<TD WIDTH=16%>";
echo "-".$row['Placa'];
echo "<BR>";
echo "<HR>";
echo "-".$row['NomeRecurso1'];
echo "</TD>";



echo "</TR>";
echo "</TABLE>";

} ?>
[/codebox]

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

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.



  • Forum Statistics

    • Total Topics
      152k
    • Total Posts
      651.8k
×
×
  • Create New...