W inpucie adresa mam liczbe , chcialbym ja przeslac do skryptu php ktory pobierze mi dane z tabeli o tym id i potem te dane wyswietlic w div wyswietl
$("#nad").click(function(){ var nad = aData[0]; $("#adresa").attr("value", nad); $.ajax({ url : 'dane.php', data: "nad="+nad, type: 'POST', success: function(count) { $("#wyswietl).html(""+count); } });
{ try{ $id = $_POST['nad']; $db = new PDO('mysql:host=localhost;dbname=xx', 'root', ''); $sql = "SELECT * FROM xx WHERE ID='".$id."'"; $res = $db->prepare($sql); $res->execute(); //count the rows if($count = $res->fetch(PDO::FETCH_ASSOC)) { } else { } } catch(PDOException $e){ //Basic error handler return $e->getMessage(); return $sql; } }
if($count = $res->fetch(PDO::FETCH_ASSOC)) { }
success: function(tab) { $("#wyswietl).html(""+tab); }
$("#nad").click(function(){ var nad = aData[0]; $("#nadaw").attr("value", nad); $.ajax({ url : '/kurier/inc/dane.php', data: "nad="+nad, dataType: "json", type: 'POST', success: function(tab) { $("#nadawca02").html(""+tab[0] +"\n" +tab[1]); }, }); });