Delete automaticaly data from db..help please!!

It should be <= as the previous posters suggested.

[php] mysql_query (“DELETE FROM testDB WHERE expirationdate <= '” . date(‘Y-M-d’) . “’”); [/php]

[php]This statement need to be include in the delete function??[/php]

That really depends on what you want to happen and how your code is structure. If you want to add it to the delete function you created sure, then you need to determine when you need to call that function to make it execute.

This is the function i create …do you think it work when i submit??

public function delete(){
$expirationdate = $_POST[‘year’], $_POST[‘month’], $_POST[‘day’];
mysql_query (“DELETE FROM testDB WHERE expirationdate <= '” . date(‘Y-M-d’) . “’”);
$r = mysql_query($q);
}

Why do you need these 2 statements in your function?

[php]$expirationdate = $_POST[‘year’], $_POST[‘month’], $_POST[‘day’];
$r = mysql_query($q);[/php]

You are not using a variable called $expiration date and you don’t have a variable called $q

[php]public function delete(){
mysql_query (“DELETE FROM testDB WHERE expirationdate <= '” . date(‘Y-M-d’) . “’”);
}[/php]

Then just call the function and it should work, test it… it is a testDB after all right?

Yes, what is the better way to call that function Topcoder??
From the submit button?? Or i have to create another button for this function?

That’s your preference.

Now i have to do the “id” variable to display the article?
Right?

Yeah, you want to display things by the primary key in the table… Just using a title name will cause issues, because you can have to articles with the same name…

What can i do?? Can you explain me…?

It’s really about learning and doing small tasks from scratch…

Here’s a good tutorial on database Normalization

http://holowczak.com/database-normalization/

Understand how things work, then jump in and code small examples.

Sponsor our Newsletter | Privacy Policy | Terms of Service