Forum Moderators: coopster
I have an access database for class registration. Basically, I'm designing a form for the company's intranet page so end users can sign up for specific classes. What I need help with is displaying the class dates in a drop down list on the form.
Here is my config file
<?php
$conn = new COM ("ADODB.Connection") or die("Cannot start ADO");
$connStr = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=F:\Wellness Program\Courtney Test Folder\Class_Registration.mdb;";
$conn->open($connStr); //Open the connection to the database
?>
<?php
//config file contains connection to the database.
require("config.php");
$today = date("m/d/Y");
$Class_Date = "SELECT Class_Date, Class_Name FROM Class_Information WHERE Class_Name = '{$_POST['Class_Name']}' AND Class_Date >= '$today' ORDER BY Class_Date";
$rs = $conn->Execute($Class_Date);
?>
<title>Class Registration Form</title>
<form method=post action=?action=check>
<table border=1 align=center><tr><td>Employee Name: </td><td><input type=text name=Employee_Name></td></tr>
<tr>
<td>Extension: </td>
<td><input type=text name=Extension</td>
</tr>
<tr>
<td>Class Name:</td>
<td><select name=Class_Name>
<option value=ARP>ARP</option><option value=Skills Day>Skills Day</option></td></tr>
<tr>
<td>Class Dates:</td>
<td><select name=Class_Date><option value=$Class_Date>$rs->Fields['Class_Date']->Value</option></td>
</tr>
</form>
</table>
I would also like to put the Class_Name in a drop down from the table as well if possible. What I need the date field to do is select the class dates for the specific class name. If I confuse anyone, let me know. I'm good at confusing myself, hehe.
Any help is greatly appreciated!
Thanks so much!
$rs = $conn->Execute($Class_Date);
so I dont know how does your database interfacing class look like but it is very simple dear,
1 - select className, ClassDate from Access.
2 - run a loop e.g
$nameDropwDown=''; $dateDropDown='';
while($row=mysql_fetch_array($sqlRes)) {
$nameDropDown .= "<option>".$row['class_name']."</option>";
$dateDropDown .= "<option>".$row['class_date']."</option>";
}
and then in the form just print these variables e.g for class name
<select name=className>
<?php echo $nameDropDown; ?>
</select>
I hope it helps
Thanks so much!
SELECT Class_Date FROM Class_Information WHERE Class_Date >= '$today' AND Class_Name = '{$_POST['Class_Name']}'
I'm not sure how to do it, and no matter what I try, the 2009 dates don't populate.
Thanks so much!
*Edit*
I figured it out, stupid me hehe.
SELECT Class_Date FROM Class_Information WHERE Class_Date >= '$today' OR Class_Date >= '01/01/2009' AND Class_Name = '{$_POST['Class_Name']}'