Description of problem: I want to get value from HTML input with php and to run query on mysql database: SELECT * FROM WHERE (value=value of ID in HTML input)
WHAT I TRY TO DO: I write HTML input:
<input id="akt_djubrenje" type="text" value="1">
THEN I WRITE PHP:
try {
/* Establish the database connection */
$conn = new PDO("mysql:host=localhost;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$result = $conn->query("SELECT * FROM akt_djubrenje WHERE ID_akt = :akt_djubrenje");
$result->execute(array(':akt_djubrenje' => $_POST['akt_djubrenje']));
...
...
etc.
ALSO I give a php file data of input fields and call php file with AJAX:
function tabela() {
$.ajax({
url: 'getdjubrenje.php', // make this url point to the data file
dataType: 'json',
data:{akt_djubrenje:$("#akt_djubrenje").val()},
async: false,
success:function(json){
var data = new google.visualization.DataTable(json);
alert (json);
// Create and draw the visualization.
visualization = new google.visualization.Table(document.getElementById('tabela_djubrenje'));
visualization.draw(data, {'allowHtml': true});
}
});
}
My problem is with HOW TO GET INPUT field VALUE from HTML and fetch with php/ajax
When I type exactly value etc. "1" instead $_POST ... all works fine, so problem is with this code.
Anybody have some idea to solve my problem?
$_POSTanywhere. If you submit your form with POST you need to change the$_GETparam to a$_POSTparam.:ajdi.