Saving A Dropdown Selection: URGENT!

I have almost completed my database access php file, but I want to access files from my program based on two dropdown menu selections. Only thing is that my program does not save my first selection. If you look through it, I echo the $dept variable several times to see when it dissappears.

It is visible until I submit the form. Any IDEAS? This would essentially complete my project!

[php]

Equipment Database

<?php $dept=$_GET['var1']; $equip=$_POST['equip']; echo $dept."here i am"; if(!isset($_POST['submit'])) { ?>

Choose a Business Unit:


<?php // ++++++++++++++LOAD DEPARTMENT DROPDOWN+++++++++ if($dept) { //Reload if a value for dept is not entered print "" ; print "$dept"; print ""; }else{ //Display forging and conventional option print"" ; print""; print"Conventional"; print"Forging"; print""; echo $dept."here" ; } //Connect and check database. $database="equipid"; mysql_connect(""); mysql_select_db($database) or die( "Unable To Connect to SQL Database"); $result1=mysql_query("SELECT `Equip_ID` FROM `machine` WHERE `Department`='$dept'"); mysql_close(); print "

"; print "Choose the equipment to be viewed: "; print "

"; print ""; while ($line = mysql_fetch_array($result1)) { foreach ($line as $value) { print "$value"; } print ""; ?>




Click Submit to Post Your Entry:

<?php

//+++++++++++++Next Screen Showing Machine Information+++++++++++++++++++

}else{

$i=0;
$database=“equipid”;
mysql_connect(“192.168.0.225”);
mysql_select_db($database) or die( “Unable To Connect to SQL Database”);
$result2=mysql_query(“SELECT * FROM machine WHERE Equip_ID=’$equip’”);

$equipnum=mysql_result($result2,$i,“EquipFile #”);
$mfg=mysql_result($result2,$i,“Mfg”);
$mfgs=mysql_result($result2,$i,“Mfg Serial and/or Model #”);
$des=mysql_result($result2,$i,“Description”);
mysql_close();

 echo $dept."here i am";

?>

Equipment Number: <?php echo $equip; ?>
Mfg Description Equip File # Serial/Model #
<?php echo $mfg; ?> <?php echo $des; ?> <?php echo $equipnum; ?> <?php echo $mfgs; ?>



<TABLE>
<tr WIDTH="1000" align="center" valign="middle">
<td WIDTH="800"></td>
<td>

<tr WIDTH="1000" align="center" valign="middle">
<td WIDTH="330" align="center" valign="middle">
<INPUT type=button value="Electrical Data" onclick=redirect1()>
</td>

<td WIDTH="330" align="center" valign="middle">
<INPUT type=button value="Mechanical Data" onclick=redirect2()>
</td>

<td WIDTH="330" align="center" valign="middle">
<INPUT type=button value="Setup Data/Reference" onclick=redirect3()>
</td>
</tr>

 </BODY>
 <BR><BR>
<?php echo $dept."here i am"; } ?>

[/php]

Fixed, if I run it through the IP address it works for some reason. It’s strange that it will not recognize one but it will recognize the other variable.

Sponsor our Newsletter | Privacy Policy | Terms of Service