Hello All,
I would like to create a form that allows users to refine their query based on drop down menu selections dynamically generated from mysql. At present I have the form working with one menu (user can only choose one item) that grabs and displays data from another table. However what I would like would be that the user can choose one or more options from each table and the query/output would be entirely on that. Below are the two scripts (ser_selection.php is the main, calling see_rec.php) that i have working with just the one drop down menu. The two tables are called servers and server_history. They are linked by the common column name of name.. any help on how to modify these to incorporate the multiple menus and SQL search would be appreciated.. thanks in advance..
SER_SELECTION>PHP********************************
<HTML>
<BODY>
<CENTER><B> View A Record From The Personal Table </B></CENTER>
<?php
personal.php
include file
include ("magops_info.php");
// define it as NULL
$sql="SELECT name,ID FROM servers";
$mysql_result=mysql_query($sql,$connection);
$num_rows=mysql_num_rows($mysql_result);
if ( $num_rows == 0 ) {
echo "Sorry there is no information";
} else {
we have records
echo "<FORM METHOD=GET ACTION=\"see_rec2.php\">";
echo "Please select a server <BR>";
echo "<SELECT name=\"rec_ID\">";
while ($row=mysql_fetch_array($mysql_result))
{
$name=$row["name"];
$ID=$row["ID"];
display results
echo "<OPTION VALUE=\"$row[name]\" >$row[name]" ;
}
echo "</SELECT>";
} # end else
echo "<BR><BR>";
echo "<INPUT TYPE=\"SUBMIT\" VALUE=\"View the details !\">";
echo "<INPUT TYPE=\"RESET\" VALUE=\"Clear me!\">";
mysql_close($connection);
?>
</FORM>
</BODY>
</HTML>
SEE_REC.PHP****************************************
<HTML>
<BODY>
<?php
see_rec.php
include file
include ("magops_info.php");
// define it as NULL
$rec_ID = "";
if (isset($_GET['rec_ID'])) {
$rec_ID = $_GET['rec_ID'];
}
$sql="SELECT * FROM servers_history Where name = '$rec_ID'";
$mysql_result=mysql_query($sql,$connection);
$num_rows=mysql_num_rows($mysql_result);
if ( $num_rows == 0) {
echo "Sorry there is no information";
} else {
we have results
echo "<TABLE ALIGN=\"CENTER\" BORDER=\"3\">";
echo
"<TR><TH>date</TH><TH>server</TH><TH>backupDescription</TH><TH>BackupStatus</TH><TH>DiskSpace</TH><TH>TotalGB</TH><TH>Percent
Full</TH><TH>FreeGB</TH></TR>";
while ($row=mysql_fetch_array($mysql_result))
{
$datetime=$row["datetime"];
$name=$row["name"];
$backup_des=$row["backup_des"];
$backup_status=$row["backup_status"];
$disk_space=$row["disk_space"];
$total_GB=$row["total_GB"];
$percent_full=$row["percent_full"];
$free_GB=$row["free_GB"];
$ID=$row["ID"];
display results
echo
"<TR><TD>$datetime</TD><TD>$name</TD><TD>$backup_des</TD><TD>$backup_status</TD><TD>$disk_space</TD><TD>$total_GB</TD><TD>$pe
rcent_full</TD><TD>$free_GB</TD></TR>";
}
} # end else
mysql_close($connection);
?>
</TABLE>
<BR><A HREF="ser_selection.php"> Back</A>
</BODY>
</HTML>