-1
Hi i have an example on dropdown + ms access + php
page1:
<font face="Verdana" color="#CC0000">
<?php
$strConn = new COM("ADODB.Connection") or die("Cannot start ADO");
$strConn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("db/dbExam.mdb"));
$strSQL = "SELECT * FROM tblKursus";
$objRec = $strConn->Execute($strSQL);
?>
<form name="form1" method="post" action="process.php">
<select name="pilihankursus">
<?php
While (!$objRec->EOF)
{
?>
<option value=<?php print $objRec->Fields(2)->Value;?>><?php print $objRec->Fields(1)->Value;?></option>
<?php
$objRec->MoveNext();
}
?>
</select>
<input type="submit" name="Submit" value="Submit"/>
</form>
page2 process.php:
<?php
$strConn = new COM("ADODB.Connection") or die("Cannot start ADO");
$strConn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("db/dbExam.mdb"));
$strVar .= "KodKursus = '".$_POST["pilihankursus"]."' ";
$SKursus = $_POST['pilihankursus'];
echo "Variable yang dipost dari page lalu(default.php) ialah";
echo "<p style=\"color:#FF8000\"> $SKursus</p>";
echo "pembolehubah ini(variable)";
echo "<p style=\"color:#0080ff\">$strVar</p>";
echo "akan menentukan table yang akan dipilih untuk dipapar dan seterusnya untuk disimpan data-data ke dalamnya";
?>
<?php
$db_conn = new COM("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("db/dbExam.mdb").";";
$db_conn->open($connstr);
$rS = $db_conn->execute("SELECT * from $SKursus");
$f1 = $rS->Fields(0);
$f2 = $rS->Fields(1);
$f3 = $rS->Fields(2);
$f4 = $rS->Fields(3);
$f5 = $rS->Fields(4);
$f6 = $rS->Fields(5);
$f7 = $rS->Fields(6);
$f8 = $rS->Fields(7);
$f9 = $rS->Fields(8);
?>
</br>
<table>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form name="form1" method="post" action="update.php">
<tr>
<td>
<input name="txtKursus" type="text" id="txtKursus" value="<?php print $SKursus; ?>">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><strong>Id</strong></td>
<td align="center"><strong>NoPendaftaran</strong></td>
<td align="center"><strong>S1</strong></td>
<td align="center"><strong>S2</strong></td>
<td align="center"><strong>S3</strong></td>
<td align="center"><strong>S4</strong></td>
<td align="center"><strong>S5</strong></td>
<td align="center"><strong>S6</strong></td>
<td align="center"><strong>S7</strong></td>
</tr>
<?php
while (!$rS->EOF)
{ ?>
<tr>
<td align="center"><input name="id[]" type="hidden" type="text" id="id" value="<?php print $f1->value; ?>"><?php $id[] = $f1->value;?> <?php echo $f1->value;?></td>
<td align="center"><input name="NoPendaftaran[]" type="text" STYLE="color: #FFFFFF; font-family: Arial; font-size: 12px; background-color: #72A4D2;" size="10" maxlength="30" id="NoPendaftaran" value="<?php print $f2->value; ; ?>"></td>
<td align="center"><input name="S1[]" size="4" type="text" id="S1" value="<?php print $f3->value; ?>"></td>
<td align="center"><input name="S2[]" size="4" type="text" id="S2" value="<?php print $f4->value; ?>"></td>
<td align="center"><input name="S3[]" size="4" type="text" id="S3" value="<?php print $f5->value; ?>"></td>
<td align="center"><input name="S4[]" size="4" type="text" id="S4" value="<?php print $f6->value; ?>"></td>
<td align="center"><input name="S5[]"size="4" type="text" id="S5" value="<?php print $f7->value; ?>"></td>
<td align="center"><input name="S6[]" size="4" type="text" id="S6" value="<?php print $f8->value; ?>"></td>
<td align="center"><input name="S7[]" size="4" type="text" id="S7" value="<?php print $f9->value; $rS->MoveNext(); ?>"></td>
</tr>
<?php
}
?>
<tr>
<td colspan="9" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
<?php
$rS->Close();
$db_conn->Close();
?><br>
azlanaziz
Newbie Poster
3 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0