php - How to use jQuery variable in SQL statement? -


myscript.js

$(".tablestyleorchideeaanbod").on("click", function() {      var value = $(this).find('tr:first td:first').html();      lastclickedvalue = value;      console.log( value );      var test = lastclickedvalue }); 

so when got clicked on table class tablestyleorchideeaanbod, var test value. let's example: hi;

so, var test = hi

now need use variable in homepage, index.php. in index.php want use variable; var test, use in mysql query.

for example:

select * thisismytable rowname = var test 

how achieve this?

$(".tablestyleorchideeaanbod").on("click", function() {      var value = $(this).find('tr:first td:first').html();      lastclickedvalue = value;      console.log( value );      var test = lastclickedvalue }); 

then use ajax send data de server

   $(".tablestyleorchideeaanbod").on("click", function() {       var value = $(this).find('tr:first td:first').html();       lastclickedvalue = value;       console.log( value );       var test = lastclickedvalue;       $.ajax({             url: 'data.php',             type: "post",             /*contenttype: "application/json; charset=utf-8",*/             data: {val : test },             datatype: 'json',             success: function (data) {                 console.log(data);              }         }); }); 

php script data.php

<?php $val = $_post['val']; // whatever want here ..... //insert sql or select ?> 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -