Hi, been having a lot of issues with sending parameters and then printing them out.
The problem is I have one page which acts as a calculator- retrieving information from a database and selecting the right one from a drop down box or a different drop down box.
This then sends either or both values from the drop downs to another page and prints out the results in a new div.
The problem is when I send value from the first page from either drop down it works fine. When I send a value from the first drop down on the next page it works fine. When i send a value from the 2nd drop down box on the 2nd page the query doesnt run.
First calc page (calc.php)-
<?php
$ticket_name = $_POST['ticket_name'];
$field_name = $_POST['$field_name'];
$threeLettercode = $_REQUEST['threeLetterCode'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Calculator</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="leftdiv">Which ticket name of three letter code?<br />
<br />
<SCRIPT LANGUAGE="JavaScript">
function navigate()
{
window.location.href = 'index.php?m=' + frmMenu.m.Value;
}
</SCRIPT>
<FORM NAME="frmMenu" OnSubmit="navigate()" action="calc3.php">
<?php
$host = "localhost";
$user = "root";
$password = "";
$database = "rio_test";
$connection = mysql_connect($host,$user,$password)
or die ("Couldn't connect to server.");
$db = mysql_select_db($database, $connection)
or die ("Couldn't select database.");
echo "<SELECT NAME=\"m\" OnChange=\"frmMenu.submit()\">";
echo "<option>IPTIS Ticket Name</option>";
$query = "SELECT * FROM new_calculator";
$result = mysql_query($query)
or die ("This entry hasn't been found.");
while($row = mysql_fetch_array($result))
{
$ticket_name = $row['ticket_name'];
$field_name = $row['field_id'];
$travel_plan_notes = $row['travel_plan_notes'];
$refund_information = $row['refined_information'];
echo "<OPTION VALUE=\"$field_name\">$ticket_name</OPTION>";
}
//////// get the 3 lettered codes and return in a drop down box.
echo "</select>";
echo "<br /><br />";
echo "<input name=\"submit\" type=\"submit\" value=\"Submit\"/>";
echo "<br /><br />";
echo "<select name=\"threeLetterCode\" OnChange=\"frmMenu.submit()\">";
echo "<option>Three letter code</option>";
$query2 = "SELECT * FROM new_calculator";
$result2 = mysql_query($query2)
or die ("This entry hasn't been found.");
while($row2 = mysql_fetch_array($result2))
{
$code = $row2['code'];
echo "<option>$code</option>";
}
echo "</select>";
//echo "<input name=\"submit\" type=\"submit\" />";
?>
</form>
</div>
<div id="rightdiv"> Results go here!
</div>
</body>
</html>
So the above page is fine. Its the 'three lettered code' drop down box in the next page that is the problem, it sends the parameter in the URL but doesn't want to return the information:
calc3.php
<?php
$ticket_name = $_POST['ticket_name'];
$m = $_REQUEST['m'];
$threeLettercode = $_REQUEST['threeLetterCode'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Calculator</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="leftdiv">Which ticket name of three letter code?<br />
<br />
<SCRIPT LANGUAGE="JavaScript">
function navigate()
{
window.location.href = 'index.php?m=' + frmMenu.m.Value;
}
</SCRIPT>
<FORM NAME="frmMenu" OnSubmit="navigate()" action="calc3.php">
<?php
$host = "localhost";
$user = "root";
$password = "";
$database = "rio_test";
$connection = mysql_connect($host,$user,$password)
or die ("Couldn't connect to server.");
$db = mysql_select_db($database, $connection)
or die ("Couldn't select database.");
echo "<SELECT NAME=\"m\" OnChange=\"frmMenu.submit()\">";
echo "<option>IPTIS Ticket Name</option>";
$query = "SELECT * FROM new_calculator";
$result = mysql_query($query)
or die ("This entry hasn't been found.");
while($row = mysql_fetch_array($result))
{
$ticket_name = $row['ticket_name'];
$field_name = $row['field_id'];
$travel_plan_notes = $row['travel_plan_notes'];
$refund_information = $row['refined_information'];
echo "<OPTION VALUE=\"$field_name\">$ticket_name</OPTION>";
}
//////// get the 3 lettered codes and return in a drop down box.
echo "</select>";
echo "<br /><br />";
echo "<input name=\"submit\" type=\"submit\" value=\"Submit\"/>";
echo "<br /><br />";
echo "<select name=\"threeLetterCode\" OnChange=\"frmMenu.submit()\">";
echo "<option>Three letter code</option>";
$query2 = "SELECT * FROM new_calculator";
$result2 = mysql_query($query2)
or die ("This entry hasn't been found.");
while($row2 = mysql_fetch_array($result2))
{
$code = $row2['code'];
$new_field_id = $row2['field_id'];
echo "<option>$code</option>";
}
echo "</select>";
?>
</form>
</div>
<div id="rightdiv"><?php
if (isset($m))
{
$query1000 = "SELECT * FROM new_calculator WHERE field_id = $m";
$result1000 = mysql_query($query1000)
or die ("Please select an entry!");
$row1000 = mysql_fetch_assoc($result1000);
$new_field_id = $row1000['field_id'];
$new_ticket_name = $row1000['ticket_name'];
$new_travel_plan_notes = $row1000['travel_plan_notes'];
$new_refund_information = $row1000['refined_information'];
echo "<strong>Ticket Name:</strong> $new_ticket_name";
echo "<br /><br />";
echo "<strong>Change of travel plans</strong>";
echo "<br /><br />";
echo $new_travel_plan_notes;
echo "<br /><br />";
echo "<strong>Refund Information</strong>";
echo "<br /><br />";
echo $new_refund_information;
}
////////////
// the second query ive tried was here
//echo $threeLettercode;
$query1001 = "SELECT * FROM new_calculator WHERE code = '$threeLettercode'";
$result1001 = mysql_query($query1001)
or die ("Please select an entry!!!! !");
$row1001 = mysql_fetch_assoc($result1001);
$ticket_name = $row1001['ticket_name'];
$new_refund_information2 = $row1001['refined_information'];
$new_travel_plan_notes2 = $row1001['travel_plan_notes'];
echo "<strong>Ticket Name:</strong> $ticket_name";
echo "<br /><br />";
echo "<strong>Change of travel plans</strong>";
echo "<br /><br />";
echo $new_travel_plan_notes2;
echo "<br /><br />";
echo "<strong>Refund Information</strong>";
echo "<br /><br />";
echo $new_refund_information2;
?>
</div>
The thing is it works for either query but not both. So if i had a query to return the results of the ticket name it works fine, or if i tried a query based on the three lettered code it works fine, but both wont work together. Ive also tried an IF ISSET thing based on the two parameters but that doesnt work.
Any suggestions where im going wrong?