How To Delete All Database Entires Older Than 30 Days?
One of the fields in my database is called ad_date which is of date type and stored dates int he format YYYY-MM-DD. I would like to perform a DELETE SQL statement in my PHP script which deletes all records with an ad_date value older than 30 days.
I knoy this is also an SQL question, but it is the 'older than 30 days' part which I'm stuck with and so figured it would be better in the PHP forum as I think I need to use PHP to calculate todays date - 30 days.
View Complete Forum Thread with Replies
Related Forum Messages:
Delete Entries 1 Week Old Or Older.
I have a query that's supposed to remove bulletin entries that are a week old and over, but its not working, and the "date" column is filled with "time();" <?php mysql_query("DELETE FROM `bulletins` WHERE `date` > (time() + (3600*24*7))");?>
View Replies !
Delete Record If Older Than 5 Minutes?
Can someone help me in writing a query command, to delete a record, if the last_update field on a record is older than 5 minutes? My table has a last_update field, which holds a value as this for example: 2007-04-08 01:33:12 I need a query that when I access a php file, if a record is older than 5 minutes, it will delete it.
View Replies !
Listing Unique Entires In Database
how would i go about creating accessible folders at moment i have data in single table in database i would ideally want a system that lists all categories (by using folders or otherwise) and then enable user to either open addto delete edit each folder. could i create a column called categories and then call all unique entries. or should i create a new table for each category and then call each table.. but then id have too many tables.
View Replies !
Delete Files That Are 4 Days Old
i have a code that deletes files that are certain days old, but i dont know exactly how old and i wanted to increase it to delete files that are 4 days old. unlink $filename if $current - (stat $filename) [10] > 1 * 60 * 60 * 24;
View Replies !
Delete Field After X Days?
I have a table containing user created data, and once this data is 30 days old id like to delete it from my database. Whent the data is uploaded initially i add date(Y-m-d); to my database, however i cant get my head around how to add 30 days to this and check it. so, i was considering creating another field to hold a unix timestamp when the data is uploaded, then simply seeing if this field was less than the current timestamp minus 2592000 (30 days in seconds).
View Replies !
Update All Records In A Database 364 Days
I have a calendar with events for this year in a SQL database that I would like to use for next year too (the events will remain the same). The days of the week are important; what is on Monday, November 6, 2006 should be on Monday, November 5, 2007. I will copy the existing table to another table for the next year, so what I would want to do is update the dates to be 364 days from each date. Does anyone know a command that I can update all records by 364 days? The table is practice07 The field is PracticeDate (that holds the date that I want to update)
View Replies !
Validating TEXT Field Entires
Because I have several TEXT fields in my MySQL database, I need to know how to validate that only alphanumeric characters have been entered -- as this data will be echoed back to the user upon completion of the form. Therefore, I need to prevent any malicious text from being entered into the form (SSIs, HTML formatting, etc.) Is there any way to do this? So far, I've only been referred to addslashes(). I've managed to use the following function: function validate_text($text) { $text = addslashes($text); return ($text); } $input_text = validate_text($input text); But this only escapes single and double quotes with the slash. URLs, SSI statements, etc. remain untouched.
View Replies !
How To Display Only Entires Where Certain Field Is Present
I am trying to display some data from my database. I only want to display the entires that have a certain field populated. EG. If I have a list of names and addresses, only some of which have phone numbers. I want to call only the entries which have phone numbers and display them. What do I do with the where statement?
View Replies !
Sort Results By Date/time, Limit 5 Database Entries Of Today &/or Upcoming Days
I'm designing a website for my fraternity and in the database I have entries which contain past events, todays events, and upcoming events. My problem is that I can not figure out how to sort the query results to display: 1) only past events based on the CURRENT DATE 2) only the events which fall on the CURRENT DATE or after, limiting the results to 5 entries 3) all events that fall on CURRENT DATE or afterwards Example: Today is September 15, 2007 Problem 1) Displaying all events that happened before September 15, 2007 Problem 2) Displaying only 5 results that fall on September 15, 2007 or after Problem 3) Displaying all events that are happening on or after September 15, 2007 And obviously I would like the CURRENT DATE to change depending on what date it is, currently. Ok so now I've been very redundant in my explanation of my problem here is the code and a link to what that particular page looks like. Code:
View Replies !
Delete From Database
I have code that does not delete from a database. The same code (cut an paste in the same file, but different function and having a different query) works. So, of course, I tested the query interactively. I echoed the query and did a cut and paste when interactively connect to the database. That one worked so it isn't the query since interactively it is seeing exactly the same thing as the code produces. Here is the code: function deleteCatalog($catalog) { $query = "DELETE FROM CatalogNames WHERE sCatalogID='" . $catalog . "'"; mssql_select_db($database_Login, $_SESSION['Login']); $result = mssql_query($query, $Login); ... } The $query echos: DELETE FROM CatalogNames WHERE sCatalogID='CMP' As an example of code that works (in the same file) function addToCatalog($cat_id, $cat_name) { $query = "INSERT INTO CatalogNames (sCatalogID, sCatalogName) " . "VALUES ('" . $cat_id . "', '" . $cat_name . "')"; mssql_select_db($database_Login, $_SESSION['Login']); $result = mssql_query($query, $_SESSION['Login']); ... } The second and third lines are identical (cut and pasted) as in other places in the same code. In fact, it is only in this file that I do all the database work. Every other function works. This is the only delete, however.
View Replies !
Delete Database
using php and mysql how can i tell the my website to move any entry older than 30 days to a different table and then delete it below i have some script i did try but this doesnt work (im using unix timestamp incase that changes anything) mysql_query(" INSERT INTO newsarchive (id, postdate, title, newstext) SELECT id, postdate, title, newstext FROM news WHERE postdate < DATE_SUB(curdate(), INTERVAL 30 DAY)"); mysql_query("DELETE FROM news WHERE postdate < DATE_SUB(curdate(), INTERVAL 30 DAY)"); mysql_close($link); //clean up
View Replies !
Recursive Database Delete
I have two tables in my database, one for the folders, where each folder has a parent id and an id itself, and one for the files where each file has a parent id for the folder its in. Now If the user deletes a folder, every file and folder within it, no matter how many there are, should be deleted. Can anyone give me the idea?
View Replies !
Delete Item From Database
I still can't figure out how to delete an item from my shoppingcart. I have tried different ways to do this, but its impossible. -a button or link that deletes a item from my database -the php script that deletes it here is a suggestion: $slett = "DELETE ID, VARE, MODELL, STR, ANTALL, PRIS, TOTALPRIS FROM USER_TRACK WHERE USER_ID = "$user_id""; But how can i assign this to a button?
View Replies !
Delete Row In Database By A Selectbox?
I'm having a world of trouble with this. I have a selectbox of names....when they selectone and hit delete I want it to delete it from the database. I dont think i'm getting any value from the select box. Here is the code I have : PHP Code:
View Replies !
Delete A Row From A Database Table
I'm trying to delete a row from a database table. I've made a connection yet it's not working. Is there something wrong with the following code? mysql_query("DELETE * from `contactinfo` WHERE Submission_Number = 1 ");
View Replies !
How To Delete MySQL Database.
I've got three hostings with the GoDaddy hosting service. The hostings are supposed to provide only one MySQL database each. I've just recently noticed in the phpMyAdmin program that separate databases, each with the name "test," has appeared in two of the three hostings. I don't know how they got there. I didn't put them there. I contacted GoDaddy's technical support. They said that the "test" databases automatically comes with the phpMyAdmin program. Of course, that's not right. Anyway they said that I could delete the extra database without damaging anything.
View Replies !
Delete Data From Database
Let's say i have two tables, table_one; userid,userinput,indexno table_two; cond,qant,amp,indexno the indexno in table_one and table_two are the same.if i choose to delete one row of data in table_one,i want the data with the same indexno in table_two be deleted as well. how can i achieve this?
View Replies !
Database Auto Count What About Delete?
I have a table that give a unique ID to certain Articles. To give the ID i simply use the Auto count of the DB. But what happens when i delete a record? i am now missing an ID. How can i insert a row and give it the first available number? For example ID 1, 2, 4, 5, 6 i would Insert and set the ID number to 3.
View Replies !
Delete Data From MySQL Database
I am new to PHP and MySQL but I have setup a MySQL database. I can view the information in an HTML table using PHP scripts and can delete an entry form the database table, but what i need to do is to be able to delete an entry by selecting a radio button next to the relevent information however when i try to add a form in the PHP script i get an error.
View Replies !
Database Update/edit And Delete
i have spent the last few days trying to create a simple script to add/edit and delete entries in a mysql database with php. i have 1 database with 40 tables, each table has 3 fields (id, header and body) i created an input page with input fields for header and body. the table to store the information in is selected from a drop down menu. all this works fine. for some reason i cannot get the edit and delete page top work at all. would someone mind taking a look at the code and let me know what i am doing wrong? Code:
View Replies !
Delete From Flat File Database ?
I have recently started to code a Flat file database (just for fun) and it's going fine, but I was wondering whats the best way to delete a line from the file. I have this code below and I would like to add a delete button besides each line, which would obviously delete that line. But I do not know the best way to go around doing this as I don't know any specific functions to use. Code:
View Replies !
Simplify Insert-update-delete From Database
I'm looking for some functions or objects allowing to select-insert-update-delete from any table in a mysql database without the need to create a new query every time. Example: selectdatas(array('field1','field2','fieldn'),arra y('table1','tablen'),array('left join,idy','inner join, idx')) then the function build the query, execute it and then return an object with the query result. I must build a database driven site that is 90% of the time spent on building queries. If I may avoid build them manually it will help me a lot and let me gain some days of programming.
View Replies !
DELETE TimeOut Issue On A Large Database
When I run the script below, it results in a timeout. Running the commands through phpMyAdmin, results in a timeout too. Table1 has 40,000 records and Table2 has 35,000 records. I run the script to get rid of the duplicates. Is there a way that I can check for duplicates without the timeout issue? I tried the while loop through PHP and that results in a timeout too. Code:
View Replies !
Delete Database Base On User Choice
i want to let user delete their data from database. Note: one user may have more than one rows of data. table as following; TCid UserName Topic Content 1 q1 aa aa 2 q2 aa aa 3 q3 aa aa 4 q1 aa aa 5 q2 aa aa And i code as following steps; 1) ask user input user name 2) Display out all the data which the users got. (it is in delete.php file.) in here, i will use the check box, to let the user choices which data they will delete. note: i will try to make the Cid relate with the input name, so later on i can delete the data base on Cid. 3) i will delete the data base on the user choice(it is in deleteR.php file). but at the movement, i just want to test where i can get the value of the TCid or not (because i will delete some datas base on the TCid which the user choiced). The problem i go now, it is from the step 3, i could not get the TCid's value out, that's mean, i could not delete some data base on the user choiced. Code:
View Replies !
Delete Multiple Records In The Same Database Querie?
I have some code that deletes records from the database, in a loop. However its prety inificient as it makes a seperate database call in every loop whcih is slow. PHP Code: for ($i=0; $i<count($idarray); $i++) db_query("delete from clicks where id='$idarray[$i]'"); Is their a more efficient way of doing that? It is posible to delete multiple records in the same database querie?
View Replies !
Simple Login Page To Delete And Edit Things In Mysql Database
How do I build a simple login page on my site? I need a way to login to my admin area in my webshop, so I can add, delete and edit things in mysql database. I don't need help with add, delete and change things, only the login thing. The users should not even know that there is a admin login page. The users don't login to shop, they just shop so I can't use the user login page because there is no such page. Can someone please give me some guidelines for this?
View Replies !
Older PHP Manuals?
I'm trying to use the DOM XML functions, but because they're in development and my hosting provider only has 4.0.4 installed, I don't have the proper documentation. Does anyone know where I can locate an older version of the php manual?
View Replies !
Clearing Up Older Files
Wonder if you bunch can help me (again!)... i'm looking for a way to read the filenames and dates in a directory, and delete everything which is more than 24 hours old. It's gonna be part of a garbage cleaning routine for old temporary downloaded files.
View Replies !
Show Older Entries
I have a MySql table with the field "sentdate". How could I set up a query that selects only entries that have a sentdate that is for example 30 days old?
View Replies !
How Do I Get First Timestamp Older Than 24hours?
I would like to query results of post timestamps (say 10 results sorted in DESC order) and have it read the timestamp of the most recent... Then go through the remaining 9 results and return the next timestamp that is at least 24 hours (or 86,400 seconds) old or older... Is an if/elseif/else the only way to do it or is there something more elegant/efficient? Also, is there a way to stop it if there aren't 10 results available?
View Replies !
Download PDF In IE6 Older Versions
I have a script to download text and pdf documents from a site but am encountering problems in older versions of IE. I have adapted the script that we have in house to the following. If anyone can spot out any flaws or offer critique please comment. The main problem the client has is that a white screen appears when the button is clicked. <input type="button" value="Download" onclick="window.location='/about_us/jobs/?action=downloadFile&documentID={$key}'" /> private function downloadFile() { $documentID = intval(stripslashes(strip_tags($_GET['documentID']))); if ($this->db->fetch_result($this->db->query("SELECT COUNT(*) FROM job_documents WHERE documentID = $documentID"))!=1) { header('Location: /about_us/jobs/'); exit; } $jobID = $this->db->fetch_result($this->db->query("SELECT jobID FROM job_documents WHERE documentID = $documentID")); $this->forceDownload($documentID,$jobID); ...
View Replies !
Deleting Older Entries.. (mysql)
I've a comment form.. I've allowed only 10 comments to be viewd, so when I submit new comments, I want to know how to delete older ID comments except the latest 10 comments. Means if there are 13 comments.. 13...3 shd be there and very 1st and 2nd(older) comments must be deleted.
View Replies !
Query For Records Older Than A Date?
I need to write a query for a table that has records that are up to 5 years old. I need the query to return records that are older than 6 months only. There is a date field in the table. Using date_sub and interval I know how to get records between today's date and an interval, but not records older than that interval. select * from tables where date_checked BETWEEN DATE_SUB(CURRENT_DATE(),INTERVAL n DAY) AND CURRENT_DATE();
View Replies !
Deleteing MySQL Rows Older Than 1 Hour
Hi, as the title says, I have a mysql table which logs data, I have a timestamp field which collects what time the record was added, I really need to know howto setup a WHERE clause which will tell mysql to delete rows that are older than one hour, can anyone help?
View Replies !
Older GD Lib And Jpeg Photo Thumbnail Generation
I'm using a server which only has GD version 1.6.2, with jpeg support enabled. I'm trying to use it to make thumbnails of jpeg photos as they are uploaded from a webform, but moving from my development server (which has GD 2.x) to the real server I noticed the lower GD lib version, and that it doesn't support imagecreatetruecolor. Without this, using imagecreate, the converted image always come out almost always a single colour, or with very little variation in the colour. Using some images I found in XP as a test, one has green plants with a few bright red flowers - if i just use imagecreate, the bright red flowers are green too. I'm using imagecopyresampled to do the copy. Is there another way to do this without getting newer libraries installed on the server?
View Replies !
MYSQL PHP Code Works With Older Version.
I am having issue with they way that my PHP MYSQL code works with the MYSQL version 5.0.45 Here is the Code that inserts the data into the database. The thing is the tables that have a int in MYSQl error when there is no value present. Code:
View Replies !
MySQL Dont Show Older Than Today
I'm making a database for upcoming shows. so, what I wonder now, is there a way to show only upcoming shows, and just exclude the shows older than todays date? what I've got atm is: Code:
View Replies !
Migrating Existing Site From Older Version Of PHP & MySQL
There's an existing website (on a single box running Linux, Apache, PHP 4.1.2, MySQL 3.23.58) that I need to migrate over to another setup (2 boxes, the web/app server running MS 2003 Server, IIS6, PHP 5.2.4 and a DB box running on SuSE, MySQL 5.0.26). I've gotten the connection between the two new boxes to work, but a lot of the code from the original website doesn't seem to work. Is there anything obvious I should know about migrating code from the older setup to the newer one, which is running different versions of PHP and MySQL. I've attached 2 php files (both renamed to txt). When I bring up the dir_master.php file, the only thing that comes up is the Name, Affiliation, and Department headers from the contents.php file.... nothing gets displayed from the MySQL database. Like I said, I have been able to pull stuff out of the DB using code I wrote myself to test it, so I'm sure the PHP to MySQL connection is working. I think the issue might be with the PHP code and how the HTML is embedded in it, but like I said, this isn't my field of expertise. I'm hoping there's a quick syntax fix that I can use without having to completly rewrite everything.... especially since there's a number of PHP files that will need to get changed.
View Replies !
Delete Record - When The Delete Link Is Clicked The Next Page Is Blank And Nothing Is Deleted.
This is my "delete.php" and this "todo/delete.php?id=64" an example of a link to it generated from the index.php page. When the delete link is clicked the next page is blank and nothing is deleted. What have I done wrong? <? include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $id="delete from todo where id='$id'"; mysql_query($id); mysql_close(); ?>
View Replies !
|