Re: Get and Post Headache
Posted: Wed Dec 08, 2010 8:08 pm
Just do it and I'm pretty sure it will work.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<html>
<head>
<title>Modify Current Inventory</title>
<link rel="stylesheet" href="CSS\standard.css">
</head>
<body align="center">
<h2>Modify Current Inventory</h2>
Select the part number from the drop-down list to modify.
<?php
include 'admin\db_inventory.php';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to database');
mysql_select_db($dbname);
$query = "SELECT DISTINCT partnum FROM parts;";
if($result = mysql_query($query))
{
if($success = mysql_num_rows($result) > 0)
{
echo "<form method='post' name='partnum' action='get_inventory.php'>";
echo "<select name='partnum' onchange='getInventory(this.value);'>\n";
echo "<option>-- Part Number --</option>\n";
while ($row = mysql_fetch_array($result))
echo "<option value='$row[partnum]'>$row[partnum]</option>\n";
echo "</select>\n<p />";
}
else { echo "No results found."; }
}
else { echo "Failed to connect to database."; }
mysql_close();
?>
</form>
<div align="center" id="txtHint"></div>
<script type="text/javascript">
function getInventory(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
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","get_inventory.php?q="+str,true);
xmlhttp.send();
}
</script>
<br />
<FORM>
<INPUT TYPE="button" VALUE="Home" onclick="window.location.href='index.php';" />
<INPUT TYPE="button" VALUE="View Inventory" onclick="window.location.href='current_inventory.php';" />
</FORM>
</body>
</html>Code: Select all
<html>
<head>
<title>Modify Current Inventory</title>
<link rel="stylesheet" href="CSS\standard.css">
</head>
<body align="center">
<h2>Modify Current Inventory</h2>
Select the part number from the drop-down list to modify.
<?php
include 'admin\db_inventory.php';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to database');
mysql_select_db($dbname);
$query = "SELECT DISTINCT partnum FROM parts;";
if($result = mysql_query($query))
{
if($success = mysql_num_rows($result) > 0)
{
echo "<form method='post' name='partnum' action='get_inventory.php'>";
echo "<select name='partnum' onchange='getInventory(this.value);'>\n";
echo "<option>-- Part Number --</option>\n";
while ($row = mysql_fetch_array($result))
echo "<option value='$row[partnum]'>$row[partnum]</option>\n";
echo "</select>\n
<p />
</form>";
}
else { echo "No results found."; }
}
else { echo "Failed to connect to database."; }
mysql_close();
?>
<script type="text/javascript">
function getInventory(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
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","get_inventory.php?q="+str,true);
xmlhttp.send();
}
</script>
<div align="center" id="txtHint" />
<br />
<FORM>
<INPUT TYPE="button" VALUE="Home" onclick="window.location.href='index.php';" />
<INPUT TYPE="button" VALUE="View Inventory" onclick="window.location.href='current_inventory.php';" />
</FORM>
</body>
</html>