The code below pulls
out a list of fields from a database and populates a list box with
them.
print qq!<form method="POST" action="whatever.cgi">!;
$SQL = "SELECT DISTINCT MachineNames.MachineName FROM MachineNames WHERE NOT(((MachineNames.MachineName)=''))ORDER BY MachineName ASC ";
&SQL; #runs the sql command
print qq!<font size="3"><b>Recorder</b></font>\n!;
print qq!<select name="rec">!;
$SQL = "SELECT DISTINCT MachineNames.MachineName FROM MachineNames WHERE NOT(((MachineNames.MachineName)=''))ORDER BY MachineName ASC ";
&SQL; #runs the sql command
print qq!<font size="3"><b>Recorder</b></font>\n!;
print qq!<select name="rec">!;
while ($db->FetchRow())
{
@values = $db->Data();
foreach $var (@values)
{
print("<OPTION VALUE=$var>$var</OPTION>");
}
}
print ("</select>");
&CLOSEDB;
print("</form>");
{
@values = $db->Data();
foreach $var (@values)
{
print("<OPTION VALUE=$var>$var</OPTION>");
}
}
print ("</select>");
&CLOSEDB;
print("</form>");
According to what
item the user picks i want to pass it onto another query - but it doesn't seem
to allow me to pass in a field with spaces?? anyone know
why
I read the value
selected in :
my $rec =
param("rec");
then pass it to
another sql statement :
$sql =
qq!SELECT TransientsList.Location, TransientsList.MachineName,
TransientsList.TriggerTime, TransientsList.Duration,
TransientsList.Description, TransientsList.CauseOfTrigger,
TransientsList.Classified, TransientsList.RecNum
FROM TransientsList where ((TransientsList.MachineName)='$rec') ORDER BY TransientsList.MachineName!;
FROM TransientsList where ((TransientsList.MachineName)='$rec') ORDER BY TransientsList.MachineName!;
If $rec
"Hello" this query will work.
However,
"Hello 1" won't anybody know how i get around this ?
