class manage {

    private $entryId;

    function __construct($entryId) {
        $this->entryId = $entryId;
    }

    function deleteEntry() {
        //delete $this->entryId from database
    }

}

$m = new manage(23);
$m->deleteEntry();

how this method delete entry from db deleteEntry();

how sql query works with this

please help to understand

Recommended Answers

If you have object for database then that function can be used.
otherwise,

<?
	 function deleteEntry() {
        return mysql_query("delete from manage where entryId='".$this->entryId."'") or die(mysql_error());//delete $this->entryId from database
    }
?>
Jump to Post

All 3 Replies

If you have object for database then that function can be used.
otherwise,

<?
	 function deleteEntry() {
        return mysql_query("delete from manage where entryId='".$this->entryId."'") or die(mysql_error());//delete $this->entryId from database
    }
?>

Thanks

I think This code needs intval() before assigning number.

function __construct($entryId) {

$this->entryId = intval($entryId);

}
Be a part of the DaniWeb community

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