0
Hello!
I have a button
html with a value
which is generated from a foreach
, following example:
foreach ($array_informado as $rows){
if (mysqli_num_rows(consulta_imei($rows))>0) {
$valores_consulta = mysqli_fetch_row(consulta_imei($rows));
if ($rows = $valores_consulta[0]) {
if ($valores_consulta[21] == 0) {
echo "<tr class='table-success'>";
echo "<th scope='row'>
<button type='submit btn-sm' id='liberar' value='".$rows."' onClick='capturaimei(this.value);' class='btn btn-success'>Lib</button>
<button type='submit btn-sm' id='bloquear' value='".$rows."' onClick='capturaimei(this.value);' class='btn btn-warning'>Bloq</button>
";
}
By clicking on any of these buttons
(release or block) I have to capture the field value
and call a function in php by running a UPDATE
in the database with this value as a parameter.
In this case, the javascript function is giving an Alert:
function capturaimei(imei) {
alert(imei);
}
These are my updates, where they receive the code as parameter:
function lock_travapda($imei){ // bloqueia os aparelhos que vem por parametro
include('con.php');
include_once('con.php');
$query_block_travapda = "update jupiter_controle set travapda = 1 where imei in ($imei)";
$rs_block_travapda = mysqli_query($con,$query_block_travapda) or die(mysqli_error($con));
mysqli_close($con);
The question is this, how can I call this function locktravapda
passing through parameter the captured code with the value
button?
Follow prints of the visual part to facilitate understanding:
Grateful
If it is by AJAX, search on the site a lot of material on the subject.
– Sam