Ok so the user goes to my script called team.php wich is this code
<script>
// Create the AJAX xmlHttpRequest object
function createRequest()
{
var xmlhttp = false;
try {xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}catch(E){xmlhttp = false;}}
if(!xmlhttp && typeof XMLHttpRequest!='undefined'){try{xmlhttp = new XMLHttpRequest();}catch(e){xmlhttp=false;}}
if(!xmlhttp && window.createRequest){try{xmlhttp = window.createRequest();}catch(e){xmlhttp=false;}}
return xmlhttp;
}
// Make an AJAX xmlHttpRequest to test_query.php
function show_value(v)
{
/* Change test_query.php to the name of your PHP page. */
var php_page = "test_query.php";
var url = php_page+"?common="+v;
var con=createRequest();
con.open("GET",url,true);
con.onreadystatechange=function()
{
if(con.readyState==4 && con.status==200)
{
document.getElementById("showValue").innerHTML=con.responseText;
}
}
con.send(null);
}
</script>
<table align="center" border="2" bordercolor="005DB3">
<tr>
<td background="untitled.gif"><center>Challenge Team</center></td>
</tr>
<tr>
<td bgcolor="FFFFFF">Ladder:
<select onchange="show_value(this.value)">
<option value="">Make a Selection</option>
<option value="fsr">FS Rounds</option>
<option value="fsta">FS Time Attack</option>
<option value="tr">Tech Rounds</option>
<option value="tta">Tech Time Attack</option>
</select>
<div id="showValue"></div>
</td>
</tr>
</table>
</form>
You there is no submit button because based on there selection test_query.php comes along and adds another dropdown, submit button then submits a query. Here is test_query.php
<?php
require_once('./forum/SSI.php');
require_once('./mysql_connect.php');
$username = $context['user']['name'];
$query_value=empty($_GET["common"])?"":$_GET["common"];
$userteamcheck = "SELECT * FROM smf_members WHERE memberName='$username'" or trigger_error("Query: $userteamcheck\n<br />MySQL Error: ". mysql_error());
$userteamcheck2 = mysql_query ($userteamcheck);
while ($userteamcheck3 = mysql_fetch_assoc($userteamcheck2)) {
$teamnamme = $userteamcheck3['team'];
$currentpointsp = "{$query_value}p";
$a = "a{$query_value}";
$fetchpoints = "SELECT * FROM aacl_team WHERE teamname='$teamnamme'" or trigger_error("Query: $fetchpoints\n<br />MySQL Error: ". mysql_error());
$fetchpoints2 = mysql_query ($fetchpoints);
while ($fetchpoints3 = mysql_fetch_assoc($fetchpoints2)) {
$currentpoints = $fetchpoints3["$currentpointsp"];
}
$fetchmorepoints = "SELECT * FROM aacl_team WHERE $query_value!='0' AND $a='0' AND $currentpointsp <= $currentpoints AND teamname != '$teamnamme' LIMIT 1" or trigger_error("Query: $fetchmorepoints\n<br />MySQL Error: ". mysql_error());
$fetchmorepoints2 = mysql_query ($fetchmorepoints);
while ($fetchmorepoints3 = mysql_fetch_assoc($fetchmorepoints2)) {
$morepointteam = $fetchmorepoints3['teamname'];
$morepointteamid = $fetchmorepoints3['id'];
}
$fetchlesspoints = "SELECT * FROM aacl_team WHERE $query_value!='0' AND $a='0' AND $currentpointsp >= $currentpoints AND teamname != '$teamnamme'" or trigger_error("Query: $fetchlesspoints\n<br />MySQL Error: ". mysql_error());
$fetchlesspoints2 = mysql_query ($fetchlesspoints);
while ($fetchlesspoints3 = mysql_fetch_assoc($fetchlesspoints2)) {
$lesspointteam = $fetchlesspoints3['teamname'];
$lesspointteamid = $fetchlesspoints3['id'];
echo "
<form action=\"test_query.php\" method=\"post\">
<select name=\"cteam\">
<option value='" . $morepointteamid . "'>" . $morepointteam . "</option>
<option value='" . $lesspointteamid . "'>" . $lesspointteam . "</option>
</select><div align='center'> <input type='submit' name='challengeteamsubmit' value='Challenge' /> </div>
<input type=\"hidden\" name=\"challengeteamsubmit2\" value=\"TRUE\" /></form>";
}}
if(isset($_POST['challengeteamsubmit2'])){
srand((double)microtime()*1000000);
$arry_txt=preg_split("/--NEXT--/",join('',file("times.txt")));
$randomtime = $arry_txt[rand(0,sizeof($arry_txt)-1)];
$randomdate = date('l j F Y', strtotime('+' . rand(7,14) . ' days'));
$teamid = $_POST['cteam'];
$query1 = "INSERT INTO aacl_match (`team`, `ladder`, `time`, `date`, `teamchallenged`) VALUES ('$teamnamme', '$query_value', '$randomtime', '$randomdate', '$teamid')";
$result1 = mysql_query ($query1) or trigger_error("Query: $query1\n<br />MySQL Error: " . mysql_error());
}
?>
Now you know where the $query_value comes from this is the problem. In test_query.php if do
echo "$query_value";
above the line
if(isset($_POST['challengeteamsubmit2'])){
It will echo a result out based on the dropdown. But if I do it bellow it echos blank how do I get it to echo the result even underneath the if/isset.
Hope this is clear. Thanks