Good afternoon.
Now I ask you to highlight my little programming experience. If my question does not fit well with the theme that I am going to present, I apologize. I ask for your help and cooperation.
I'm doing a garage project in which I have two check boxes. One that selects the vehicle by the license plate and another of the driver that selects by name. Below is the layout
WhenIselectthevehicle,itsearchesthedatabaseforallitsowndata.Thefieldsfromwhichitwilldepositthedatathatwillbefetchedfromtheselecteditemareoutlinedbytheredlines.
Theemployeecheckboxisthesamedilemma,however,it'sthegreenlinefields.
Basically,Iselectthevehiclelicenseplate/drivernameandthusaqueryisdoneusingthenameplateorthedriver'snameintheWhere.I'lltrytoexplaininmoredetail:Whenselectingtheitem,itwill"reload" the page and will bring the value selected by "$ _POST", like:
Plate selection box:
<select id="placas" name="placa" onclick="if (this.value != ''){this.form.submit()};">
<option value="">- PLACAS -</option>
<?php
$i=0;
while(odbc_fetch_row($sql))
{
$i++;
$placa=odbc_result($sql,"PLACA");
?>
<option value="<?php echo $placa; ?>" ><?php echo $placa; ?></option>
<?php } ?>
</select>
$_POST:
$var = $_POST['placa'];
From this point, it will use the variable "$ var" to make the filter in the query. How:
$sql1 = odbc_exec($conn1," SELECT ID_FLASHPT AS 'ID',
NOME_VEICULO AS 'NOME',
PLACA_VEICULO AS 'PLACAS',
MARCA_VEICULO AS 'MARCA',
QUILMT_VEICULO AS 'QUILOMETRO',
DOCMT_VEICULO AS 'DOCUMENTO',
COR_VEICULO AS 'COR',
COMBTVL_VEICULO AS 'COMBUSTIVEL',
ANO_MODL_VEICULO AS 'MODELO',
ANO_FABRC_VEICULO AS 'FABRICACAO',
OBS_VEICULO AS 'OBS'
FROM FLASHPT
WHERE PLACA_VEICULO = '$var'");
In the case a filter would be made from the variable $ board or $ driver in the Where of Query.
So far, it works. When you select the option, it will "reload" the page and bring the value selected in the checkbox of the board to $ _POST and write to a variable (in this case, "$ var") and thus use that variable to do Query and stores the filter values into variables that will be passed to the inputs. How:
Values that will be filtered from "$ var" and stored in variables to be passed to an input shortly after.
$nome=odbc_result($sql1,"NOME");
$marc=odbc_result($sql1,"MARCA");
$quil=odbc_result($sql1,"QUILOMETRO");
$doc=odbc_result($sql1,"DOCUMENTO");
$cor=odbc_result($sql1,"COR");
$comb=odbc_result($sql1,"COMBUSTIVEL");
$mod=odbc_result($sql1,"MODELO");
$fab=odbc_result($sql1,"FABRICACAO");
$placas=odbc_result($sql1,"PLACAS");
$obsveiculo=odbc_result($sql1,"OBS");
Inputs: These inputs are those circulated by red or green lines, in the present image above.
<input type="text" maxlength="10" minlength="8" required placeholder="Placa" disabled style="font-size: 15pt;" value="<?php echo $placas ?>" name="placaveiculo">
However, when I select the card and so reload the page bringing the values that are in the red circled inputs (same as the image in the top image) and then I will select the driver, reloading the page again to bring the data of the driver this time, it brings the data of the driver correctly, however, it erases the data of the vehicle and so on.
Please help me, if I have not had clarity in my doubt, ask me that I try to specify my explanation better
Thank you in advance.