PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Can anyone help me figure out why the $percent variable isn't posting
<?php
$postIt = $_SERVER["PHP_SELF"];
$display_block .="
<b>Choose a department to review:</b>
<form action=\"$postIt\" >
<select name=\"area\" onchange=\"this.form.submit();\">
<option>Behm</option>
<option>BronchLab</option>
<option>C/SParkPlace</option>
</select>
</form>
";
$areaSelected = $_POST['area'];
$conn = doDB();
$sql = "Select percent1 FROM data WHERE Area = '{$areaSelected}'";
$result = mysql_query($sql,$conn) or die(mysql_error());
while ($newArray = mysql_fetch_array($result))
{
$percent = $newArray['percent1'];
}
$display_block .="
the percent is $percent
";
echo $areaSelected;//nothing happens here?!?
<html>
<head>
<meta http-equiv="pragma" content="no-cache"/>
<title>KDMC - Quality Manager Admin Online</title>
<link href="ostyle.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php echo $display_block; ?>
</body>
</html>
?>
now when I select a area it does post to the as i can see it in the url[text]http://site/admin/member.php?area=Behm[/text]
but it doesnot allow me to even echo it...what the heck?
As you can see in the URL it isn't POSTING, it is GETting which is the default for the form when not specified. So either use $_GET or change the form method:
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.