I have the following code… and I am trying to pass in a parameter to replace “id = 0”, with a value. Is there a way to do that, or a better way to do it?
DB Call
include 'db.php';
$con = mysql_connect($host,$user,$pass);
$dbs = mysql_select_db($databaseName, $con);
$result = mysql_query("SELECT * FROM myTable where id = 0;");
JSON call:
$(function(){
var items="";
$.getJSON("mypage.php",function(data){
$.each(data,function(index,item) {
items+="<option value='"+item.id+"'>"+item.title+"</option>";
});
// .... some stuff
});
});
you can parse variables throw your getJSON request.
Do the following:
Php receives the variable via GET:
Make sure that you use mysql_real_escape_string() to prevent mysql injections…