Forum Moderators: coopster
<html>
<head>
<title>Committed Dollars</title>
</head>
<body>
<center><h2>Committed Dollars Database</h2></center><p>
<form method="post" action="committedmonth.php">
<input type="hidden" name="id" value="NULL">
<center>
<table border="8">
<tr>
<td><b>Project:</b></td><td align="left"><input type="text" name="project_description" size="45" maxlength="150" value=""></td>
</tr>
<tr>
<td><b>Estimated Cost:<font color=white>.........</font>$</b></td><td align="left"><input type="text" name="estimated_cost" size="8" maxlength="8" value=""><font color=red> Numeric value ONLY</font></td>
</tr>
<tr>
<td><b>Date:</b></td>
<td align="left"><input type="text" name="date" size="8"
maxlength="10" value="<? print strftime("%m/%d/%Y");?>"></td>
</tr>
<tr>
<td><b>Name:</b></td>
<td><select name="eename">
<option value = "Greg">Greg</option>
<option value = "Jeff">Jeff</option>
<option value = "Jim">Jim</option>
<option value = "Richard">Richard</option>
<option value = "Stephen">Stephen</option>
<option value = "Terry">Terry</option>
<option value = "Chris">Chris</option>
</select>
</td>
</tr>
<tr>
<td>Select Month</td><td>
<select name="target_month">
<?php
for ($select_month = 1; $select_month <= 12; $select_month++) {
$select = ( date('m') == $select_month )? 'selected="selected"' : '';
$foo = date( 'F', strtotime( date('Y') . "-{$select_month}-01" ) );
echo "\t<option $select value='$select_month'>$select_month ($foo)</option>\n";
}
?>
</select>
</tr>
<td>Select Year</td><td>
<select name="fiscal_year">
<?php
$t_date = date('Y');
for ($select_year = 2003; $select_year <= $t_date; $select_year++) {
$select = ( date('Y') == $select_year )? 'selected="selected"' : '';
echo "\t<option $select value='$select_year'>$select_year</option>\n";
}
?>
</select>
</tr>
<td>Select Contractor</td><td>
<select name="contractor">
<?php
$hostName = "localhost";
$userName = "overlac";
$password = "over321";
$dbName = "committed";
$table = "committed_tbl";
// make connection to database
mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");
mysql_select_db($dbName) or die("Unable to select database $dbName");
// Select all the fields in all the records of the Employees table
$query = "SELECT DISTINCT contractor
FROM $table";
$result = mysql_query($query);
// Determine the number of vendors
$number = mysql_numrows($result);
// Create drop-down menu of vendor names
print "View committedcjover Database List to assist in above search:
<form action=\"committedmonth.php\" method=\"post\">
<select name=\"committedcjover\">
<option value=\"\">Select a Vendor</option>";
for ($i=0; $i<$number; $i++) {
$contractor = mysql_result($result,$i,"contractor");
print "<option value=\"$committedcjover\">$contractor</option>";
}
mysql_close();
?>
</tr>
</select>
<tr>
<td colspan="2" align="center"><input type="submit" value="Enter"></td>
</tr>
</table>
</form>
</center><p>
</body>
</html>
// Create drop-down menu of vendor names
//print "View committedcjover Database List to assist in above search:
// <form action=\"committedmonth.php\" method=\"post\">
// <select name=\"committedcjover\">
// <option value=\"\">Select a Vendor</option>";
for ($i=0; $i<$number; $i++) {
$contractor = mysql_result($result,$i,"contractor");
print "<option value=\"$committedcjover\">$contractor</option>";
}
Thanks to EVERYONE for your replies. I just stumbled across this forum recently and can see how dedicated most of you are and the sense of community that exists here...
>> Iguana wrote: <option value=\"$committedcjover\">$contractor</option>
Where is the variable that you are passing as the value of the option element coming from? I can't see it from your code
<option value=\"$committedcjover\">$contractor</option>
Where is the variable that you are passing as the value of the option element coming from? I can't see it from your code