I need to write code to have a search box that will search a mssql database.

Recommended Answers

All 2 Replies

Here is my current code...

<?php
    $myServer = "*****";
    $myUser = "*****";
    $myPass = "******";
    $myDB = "*****";
    $dbhandle = mssql_connect($myServer, $myUser, $myPass)
        or die("Couldn't connect to SQL Server on $myServer"); 
    $selected = mssql_select_db($myDB, $dbhandle)
        or die("Couldn't open database $myDB"); 
    $query = "SELECT courses.course_name, courses.length_hours, course_details.objectives 
        FROM courses, course_details
        WHERE (courses.course_code = course_details.course_code) and format = 'Online' and employees = '1'";
    $result = mssql_query($query);
    $numRows = mssql_num_rows($result); 
?>
    <table border="1" id="myTable">
        <thead>
            <tr>
                <th>Course</th>
                <th>Overview</th>
                <th>Length</th>
            </tr>
        </thead>
        <tbody>
<?php
    while($row = mssql_fetch_array($result)) {
        echo "<tr><td vailgn=\"top\">" 
            . $row["course_name"] 
            . "&nbsp;</td><td>" 
            . $row["objectives"] 
            . "&nbsp;</td><td valign=\"top\" align=\"center\">" 
            . $row["length_hours"] 
            . "&nbsp;</td></tr>\n";
    }
?>
</tbody>
</table>
<?php
    mssql_close($dbhandle);
?>

I need to write code to have a search box that will search a mssql database.

Dig deep and once you have your code and hit a wall come back!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.