Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81989

How i add a function to each row selected

$
0
0

Hello,

I have a datatable working here -> http://comparador.masqueunaweb.com/buscador3.php

I need when we click on the button "Actualizar" start a function for this row.

The function i wan't to add is this one:

function descontarPrecio(data.id, data.precio, data.precioComp1, data.precioComp2, data.precioComp3){

$precioMin = min(data.precioComp1, data.precioComp2, data.precioComp3);
  $precioNuevo = $precioMin;
       --$precioNuevo;
    echo $precioNuevo;

$servername = "localhost";
$username = "";
$password = "";
$dbname = "";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$sql = "UPDATE productos SET precio = '$precioNuevo' WHERE id = '$idProducto'";

print ("<p> $sql </p>");

if ($conn->query($sql) === TRUE) {
    echo "Precio actualizado!";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();


        }

  descontarPrecio ();

That is not working, i have addapted to what i wan't,

Any help would be appreciate!


Viewing all articles
Browse latest Browse all 81989

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>