This is my first post, so bear with me.
I want to query two columns from a db and display them in a dropdown list, so that I can later select one etc.
I am using MS access as a database
I copied most of this code right out of a book, but the code is really for people using MySQL. I changed the names for the db & columns etc to suit my needs.
I've looked over everything carefully and I still don't know what's wrong. I there anyone out there who could help me out.
Could the ODBC_fech_array function be the problem?
Thanks in advance
<?php
//making a connection
$conn = new COM('ADODB.Connection');
//defining database variable
$db = 'C:\Database\groove.mdb';
//Connected to database being used in this script
$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$db");
$sql = 'SELECT testID,name
FROM test
ORDER BY testID';
$rs = $conn->Execute($sql);
if (!$sql_result) {
echo "<P>Couldn't get List!";
} else {
}
<HTML>
<HEAD>
<TITLE>Select A Cutomer</TITLE>
</HEAD>
<BODY>
<h1>Customer Lookup</h1>
<FORM method=\"POST\" action=\"admin_modrecord2.php\">
<table cellspacing=5 cellpadding=5>
<tr>
<td align=right><strong>ID/Name:</strong></td>
<td valign=top>
<select name=\"sel_record\">
<option value=\"\"> -- Select an Item -- </option>
";
while ($row = odbc_fetch_array($sql_result)) {
$testID = $row["testID"];
$name = $row["name"];
echo "
<option value=\"$testID\">$testID : $name</option>
";
}
echo "
</select>
</td>
</tr>
<tr>
<td align=center colspan=2><input type=\"submit\" value=\"Select Product\"></td>
</tr>
</table>
</FORM>
</BODY>
</HTML>
";
}
}
}
?>😕 😕 😕