I am following this tutorial - http://www.thesoftwareguy.in/multiple-dropdown-with-jquery-ajax-and-php/.. This code give a fatal error..
(Fatal error: Call to undefined method mysqli_stmt::fetch_assoc() in D:\xampp\htdocs\multiple_drop_down\index.php on line 47) PLease help me in this..
<?php
include('dbconfig.php');
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Multiple dropdown with jquery ajax and php">
<meta name="keywords" content="Multiple dropdown with jquery ajax and php">
<meta name="author" content="Shahrukh Khan">
<title>Multiple dropdown with jquery ajax and php - thesoftwareguy</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<style>
select {
padding:3px;
border-radius:5px;
background: #f8f8f8;
color:#000;
border:1px solid #EB028F;
outline:none;
display: inline-block;
width:250px;
cursor:pointer;
text-align:left;
font:inherit;
}
</style>
</head>
<body>
Multiple dropdown with jquery ajax and php
<article>
<table style="margin:0 auto;width:50%" >
<tr>
<td align="center" height="50">
<?php
$sql = "SELECT * FROM tbl_country ORDER BY country_name";
try {
$results = $conn->prepare($sql);
$results->execute();
$result = $results->fetch_assoc();
} catch (Exception $ex) {
echo($ex->getMessage());
}
?>
<label>Country:
<select name="country" onChange="showState(this);">
<option value="">Please Select</option>
<?php foreach ($results as $rs) { ?>
<option value="<?php echo $rs["id"]; ?>"><?php echo $rs["country_name"]; ?></option>
<?php } ?>
</select>
</label>
</td>
</tr>
<tr>
<td align="center" height="50"> </td>
</tr>
<tr>
<td align="center" height="50"> </td>
</tr>
</table>
(function() {
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://apis.google.com/js/platform.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
window.twttr = (function(d, s, id) {
var t, js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id))
return;
js = d.createElement(s);
js.id = id;
js.src = "https://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
return window.twttr || (t = {_e: [], ready: function(f) {
t._e.push(f)
}});
}(document, "script", "twitter-wjs"));
</div>
</article>
</div>
</div>
http://jquery-1.9.0.min.js
function showState(sel) {
var country_id = sel.options[sel.selectedIndex].value;
$("#output1").html("");
$("#output2").html("");
if (country_id.length > 0) {
$.ajax({
type: "POST",
url: "fetch_state.php",
data: "country_id=" + country_id,
cache: false,
beforeSend: function() {
$('#output1').html('
');
},
success: function(html) {
$("#output1").html(html);
}
});
}
}
function showCity(sel) {
var state_id = sel.options[sel.selectedIndex].value;
if (state_id.length > 0) {
$.ajax({
type: "POST",
url: "fetch_city.php",
data: "state_id=" + state_id,
cache: false,
beforeSend: function() {
$('#output2').html('
');
},
success: function(html) {
$("#output2").html(html);
}
});
} else {
$("#output2").html("");
}
}
</body>
0 comments:
Post a Comment