bluerain25
Technical User
hi!
new to php/mysql here. heres my code i dont know how to do this but i need help
<table align="center" width="80%">
<tr>
<td bgcolor="#3366FF" colspan=2 align="center"><b>Assigment</b></td>
</tr>
<tr>
<td><div align="right">Area:</div></td>
<td><? $query = "SELECT `areatbl`.`AreaID`, `areatbl`.`AreaName` FROM `areatbl`";
if($result = mysql_query($query))
{
if($success = mysql_num_rows($result) > 0)
{
?>
<select name='area' id = 'area' onChange="">
<option value=""></option>
<?
//Now fill the table with data
while ($row = mysql_fetch_array($result))
{
echo $areaid= $row['AreaID'];
$areaDesc = $row['AreaName'];?>
<option value='<? print $areaid ?>'><? print $areaDesc ?></option>
<? }
?>
</select>
<? }
elseif($debug)
{
die("retrieveQueryType(): No rows returned by query");
}
}
else
{
$success = FALSE;
if($debug)
{
die("retrieveQueryType(): query failed - ".mysql_error());
}
}
?></td>
</tr>
<tr>
<td><div align="right">Branch:</div></td>
<td>
<? $query = "SELECT `branchdepttbl`.`BranchDeptID`, `branchdepttbl`.`BranchDeptName` FROM
`branchdepttbl` WHERE `branchdepttbl`.`AreaID` =" .$_POST['area'];
if($result = mysql_query($query))
{
if($success = mysql_num_rows($result) > 0)
{
?>
<select name='branch' id = 'branch'>
<option value=""></option>
<?
//Now fill the table with data
while ($row = mysql_fetch_array($result))
{
echo $branchid= $row['BranchDeptID'];
$branchDesc = $row['BranchDeptName'];?>
<option value='<? print $branchid ?>'><? print $branchDesc ?></option>
<? }
?>
</select>
<? }
elseif($debug)
{
die("retrieveQueryType(): No rows returned by query");
}
}
else
{
$success = FALSE;
if($debug)
{
die("retrieveQueryType(): query failed - ".mysql_error());
}
}
?></td> </tr>
<tr>
<td><div align="right">Position:</div></td>
<td><? $query = "SELECT `positiontbl`.`PositionID`, `positiontbl`.`PositionDesc`FROM `positiontbl`";
if($result = mysql_query($query))
{
if($success = mysql_num_rows($result) > 0)
{
?>
<select name='position' id = 'position'>
<option value=""></option>
<?
//Now fill the table with data
while ($row = mysql_fetch_array($result))
{
echo $positionid= $row['PositionID'];
$positionDesc = $row['PositionDesc'];?>
<option value='<? print $positionid ?>'><? print $positionDesc ?></option>
<? }
?>
</select>
<? }
elseif($debug)
{
die("retrieveQueryType(): No rows returned by query");
}
}
else
{
$success = FALSE;
if($debug)
{
die("retrieveQueryType(): query failed - ".mysql_error());
}
}
?></td>
</tr>
</table>
at the branch query, it is supposed to display the list of branches depending on a selected area (or the value selected in the first drop down box). but my code does not work. the branch select box is gone when i preview the page.
help please.....
thanks in advance
new to php/mysql here. heres my code i dont know how to do this but i need help
<table align="center" width="80%">
<tr>
<td bgcolor="#3366FF" colspan=2 align="center"><b>Assigment</b></td>
</tr>
<tr>
<td><div align="right">Area:</div></td>
<td><? $query = "SELECT `areatbl`.`AreaID`, `areatbl`.`AreaName` FROM `areatbl`";
if($result = mysql_query($query))
{
if($success = mysql_num_rows($result) > 0)
{
?>
<select name='area' id = 'area' onChange="">
<option value=""></option>
<?
//Now fill the table with data
while ($row = mysql_fetch_array($result))
{
echo $areaid= $row['AreaID'];
$areaDesc = $row['AreaName'];?>
<option value='<? print $areaid ?>'><? print $areaDesc ?></option>
<? }
?>
</select>
<? }
elseif($debug)
{
die("retrieveQueryType(): No rows returned by query");
}
}
else
{
$success = FALSE;
if($debug)
{
die("retrieveQueryType(): query failed - ".mysql_error());
}
}
?></td>
</tr>
<tr>
<td><div align="right">Branch:</div></td>
<td>
<? $query = "SELECT `branchdepttbl`.`BranchDeptID`, `branchdepttbl`.`BranchDeptName` FROM
`branchdepttbl` WHERE `branchdepttbl`.`AreaID` =" .$_POST['area'];
if($result = mysql_query($query))
{
if($success = mysql_num_rows($result) > 0)
{
?>
<select name='branch' id = 'branch'>
<option value=""></option>
<?
//Now fill the table with data
while ($row = mysql_fetch_array($result))
{
echo $branchid= $row['BranchDeptID'];
$branchDesc = $row['BranchDeptName'];?>
<option value='<? print $branchid ?>'><? print $branchDesc ?></option>
<? }
?>
</select>
<? }
elseif($debug)
{
die("retrieveQueryType(): No rows returned by query");
}
}
else
{
$success = FALSE;
if($debug)
{
die("retrieveQueryType(): query failed - ".mysql_error());
}
}
?></td> </tr>
<tr>
<td><div align="right">Position:</div></td>
<td><? $query = "SELECT `positiontbl`.`PositionID`, `positiontbl`.`PositionDesc`FROM `positiontbl`";
if($result = mysql_query($query))
{
if($success = mysql_num_rows($result) > 0)
{
?>
<select name='position' id = 'position'>
<option value=""></option>
<?
//Now fill the table with data
while ($row = mysql_fetch_array($result))
{
echo $positionid= $row['PositionID'];
$positionDesc = $row['PositionDesc'];?>
<option value='<? print $positionid ?>'><? print $positionDesc ?></option>
<? }
?>
</select>
<? }
elseif($debug)
{
die("retrieveQueryType(): No rows returned by query");
}
}
else
{
$success = FALSE;
if($debug)
{
die("retrieveQueryType(): query failed - ".mysql_error());
}
}
?></td>
</tr>
</table>
at the branch query, it is supposed to display the list of branches depending on a selected area (or the value selected in the first drop down box). but my code does not work. the branch select box is gone when i preview the page.
help please.....
thanks in advance