Hi
I have a varible that is set at as a different value for each page this is called $mode.
Currently I have succesfully set up a drop down menu that can filter the table and refresh the results based on that filter chosen, yet I need to call this $mode variable into the query to be able to get the true results back that I require.
The php page to call the filter code is as follows
<?php
$q = intval($_GET['q']);
$con = mysqli_connect('x','x','x');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}
mysqli_select_db($con,"x");
$sql="SELECT * FROM tab1 WHERE info = '".$q."' and id='$mode' LIMIT 10";
$result = mysqli_query($con,$sql);
echo "blar blar blar
and another one that shows the results on the page
<script>
function showUser(str) {
if (str == "") {
document.getElementById("txtHint").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","info.php?q="+str,true);
xmlhttp.send();
}
}
</script>
<form>
<select name="Info" onchange="showUser(this.value)">
<option value="">Select a mod:</option>
<option value="1">this</option>
<option value="2">that</option>
<option value="3">other</option>
</select>
</form>
<br>
<div id="txtHint"><b>NEw info shows here</b></div>
IN the page that these pages that I echo the above page into, it has the variable $mode
, which sucessfully is iised in other queries in the page but $q is passed from the drop down fine but id='$mode' is showing as blank
How do I get this $mode to show the true value in this instance please?
Thanks for your help