<?php

    //Database Connection
    $connection = mysql_connect("localhost", "root","mysql");
    if(!$connection){
        die("Database connection failed: ". mysql_error());
    }

    //Select a database to use
    $db_select = mysql_select_db("school",$connection);
    if(!$db_select){
        die("Database connection failed: ". mysql_error());
    }

    //Database query
    $result = mysql_query("DELETE FROM tblstudent WHERE id=$id AND course='$course'", $connection);

    if(!$result){
        die("Database connection failed: ". mysql_error());
    }

    // Use returned data
    //while ($row = mysql_fetch_array($result)){

        //}
    mysql_close($connection);

?>          

Hi weajane01 and welcome to DaniWeb :)

Your deletion query has the following where clause:
WHERE id=$id AND course=$course

Can you confirm that the tblstudent table in your database has a primary key on the id and course field? Any other fields in the table must be included in the where clause to ensure only one record is deleted. You can try a select statement first and see if it returns exactly 1 row before deleting.

Agree to @darkagn . Or can you show how you design you tblstudent database structure?

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.