
October 28th, 2009, 04:05 PM
|
|
Contributing User
|
|
Join Date: Jul 2009
Posts: 83
Time spent in forums: 13 h 53 m 8 sec
Reputation Power: 1
|
|
|
Mssql query
Hey,
Ah, populating drop-down box was easy for MySQL, but this mssql are annoying me.
PHP Code:
$server = 'SQLSERVER';
$link = mssql_connect($server, 'username', 'password');
if(!$link)
{
die('Something went wrong while connectiong to MS SQL');
}
mssql_select_db('Exam', $link);
$options = "";
$q = "SELECT CourserId, course_title FROM Course ORDER BY course_title";
$result = mssql_query($q);
while($row = mssql_fetch_array($result)){
$course = $row['CourseId','course_title'];
$options .="<OPTION VALUE=\"$course\">";
}
mssql_close($link);
?>
Course:<select name="course">
<OPTION VALUE=0><?=$options?>
</select>
When I run the script the output is Resource id #3 (I totally don't understand why )
Also I want to connect this drop-down box with another box (based on different query ) in the sense whatever they chose in dropbox one related data will be displayed in dropbox 2. How can I do that?
Any help!
|