0
<?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);

?>          
3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by devianleong
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.