Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




How To: DELETE * FROM Table WHERE Greater Than 2 Week


I am building a module that displays the headline from a page that had the most hits last week. I was able to figure this out in PHP. I would now like to know how to delete and records that are over 2 weeks old. Anyone know how to do this in the mysql query?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
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))");?>

Can't Delete From Table!
I'm not to familiar to php and sql. I have this assignment to read from database in a table and I HAVE TO be able to push a button causing one costumer to vanish. something to do with id = $id... can anyone help me... and help me fast!

This is my code:

Delete From Table
I get this error not sure what's wrong?

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VALUES ('mortalsombat@hotmail.com')' at line 3 Code:

How To Auto Delete Table Row?
I Have A Page On My Site That The Database Outputs To. There Is A User That I Dont Want To Ban Yet , But I Do Want To Block Or auto Delete His Data. Now When Everyone Post New Data The Only Table That Would identify Them Is The Username Table, There Is No Member ID Table.

Now I Would Like To querry The Database And Auto Delete Table (Username) BOBBY And The Row BOBBY Posted , So There Is No Data Output To My Site Page For BOBBY. Can Someone Give Me A Couple Codes To Try, And I Would Think The Code Would Need To Be On A New Page That I Need To Make Up Right?

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 ");

Delete Textfile List From MySQL Table
I have a list of email addresses that I need to delete from my database and they are in a textfile, one on each line like below...

a@b.com
c@d.com
e@f.com

etc. does anybody have a snippet of PHP code that I could use to accomplish such a task?

How Do I Delete Selected Rows From MySQL Table?
I am trying to figure out how to delete selected rows from a MySQL database table. The web site that I am working on has a page that will extract rows, using the "SELECT * FROM .. etc." statement from a database and output them in a table - like the one below (bottom part). I've got that part figured out.

What I am trying to figure out is if the user puts a checkmark in one of the checkboxes (below) how would I write the PHP code to delete one or two of the rows from the MySQL table? PHP Code:

How To Delete A MySQL Database Table Without System()
I want to delete a MySQL table without using functions of the OS, so
that my php script can run on any webserver. Can I use a command like

$sql = "DELETE FROM tablename";

or are there better ways to do the job?

Multi Table Insert Delete Select Function Needed.
I am going nuts here and I know with all the functions out there, there must be an easier way to do this. Maybe someone can point me to the right tutorial or even show me how to do this.

I have a $main_id and many $sub_id tables and like to “SELECT to view” INSERT and DELETE those. UPDATE must not be but would be nice.
Here is how it looks:

Automatic Delete From MySQL Database Table Expired Records?
I have a question . . .

how can i delete from MySQL database table automatic expired records ?
?

One think is to make a service that deleting the expired records . . .

Any other method ?



Listing Table Data With An Option To Delete Each Individual Item.
Was wondering if anyone could help me with a PHP, MySQL problem. I am
completely new to PHP and MySQL. I have been trying to find a way to
list data from a table on a web page and after each individual item
have a hyperlink to allow users to delete the information listed. Can
anyone help?

i.e.
Name Age Sex
------------------------------------------
Adam 21 M delete
Betty 22 F delete
Chris 23 M delete
Daisy 24 F delete

------------------------------------------------------------------------------------------------------------------------------
(delete after 'Sex' would be the hyperlink to delete that entire line
(row) from the table).

Less Than, Greater Than
I am building a search query as i go by giving the user a number of different search options via a drop down box. I have removed all of the other search options that i am giving the user as they are irrelivent to what i am asking. The code I have so far is: Code:

Greater Than, Less Than Date
I am trying to find if a date retrieved from a mysql table is less than or equal to or greater than or equal to a particular date. I'm not sure what the correct operator to find a less than, or equal to, greater than or equal to for a date is.

I thought this was it: "<=", ">="... but can these be used with dates, and if so, is the date format, 2003-08-13, used in mysql usable in php as well?

Show All Records Greater Than 500.
I need to find out how to show all SQL records with a record id greater than 500 can anybody help me out?

I have tried WHERE id > 500 and it doesnt work

Uploading Files Greater Than PHP Allowance
What does PHP do in the following circumstances:

a) A user uploads a file that is bigger then the allowed filesize. Does it allow the file to upload and discard it? Or does it allow upload unil the size limit is reached? Htlp

b) The script timesout during an upload. What does PHP do here?

PHP Compile Help - MP Library Version 4.1.2 Or Greater Required
I am trying to compile PHP 5.0.4 on Solaris 9 with GMP. I keep getting this
error:

configure: error: GNU MP Library version 4.1.2 or greater required.

I installed GMP 4.1.4 using: ./configure --enable-mpbsd --enable-mpfr



Greater Than '>' Problem In Php Code In Html Body
if i have a greater than symbol within a section of php code, embedded with the <body> section of a .html file, then when viewing the page, the parser jumps out of the php script, and displays the rest of the script as though normal html, until a less than symbol is encountered, and it then proceeds to behave as though php again. Code:

Check Date From Input Must Greater Or Equal Today Date?
I have 3 select box. Code:

<select name="day">
<option value="1">1</option>
<option value="2">2</option>
.......
<option value="31">31</option>
</select>

<select name="month">
<option value="01"> Jan </option>
<option value="02"> Feb </option>
.....
</select>

<select name="year">
<option value="2002">2002 </option>
<option value="2003">2003</option>
</select>

When I select and click submit in form. I will have 3 variable :

$day, $month and $year

How can I check the day that I choose in form must equal or greater than today date? If it less than today date. I must print error message to user.

First Day Of A Week
hi,

i want to know the range of date for a week

example : week 3 of 2001

monday is ??
sunday is ??

how can i do with PHP ??

tx

Day Of Week ?
Is there a way I can obtain the day of week - If I have the day, month, year ?

(not via the time function - But from a database....)

Im looking through the calendar and date functions -But can't locate
anything suitable...

Day Of The Week?
is there a way to get the day of the week in php? i want to get the correct values monday, tuesday, wdenesday, etc. for the actual day it is.

Getting Day Of Week Out Of Datestamp
I currently have a datestamp in the format yyyymmdd. I want to pull the day of the week (Monday, Tuesday, etc...) out of that datestamp at any given time.

Currently my code looks like this:
$datearray = getdate($firstdatestamp);
echo $datearray["weekday"];
When $firstdatestamp = 20000501 (or the first of May, 2000) the weekday returned is Thursday when really it should be Monday!

I tried:
echo date("l", time());
and it gives me the right weekday but only for the current date. I need to pass this my datestamp and am not too sure how.

Getting Day Of The Week From A Date
I tried searching the old postings, but to no avail. I am trying to figure out a way to get the day of the week from a date. Basically, I have a date in the format of 05/02/2003 (but I can change that format easily) and I need to have my program figure out which day of the week that was. All of the dates that I have will have already passed.

Date Of The Week
Can anyone help me? I am trying to work out the timestamp for the first DATE (not day) of the current week and last date of the current week. Any ideas?

Date To Week # Fct
I'm searching a PHP function that would translate a date in the following
format yyyymmdd to the week number in the year...
ex : 20040128 => 5
i.e. jan 28th 2004 gives week nb 5 in 2004.

Week Of Year
Is there a function which returns the week of the year, given a specific date?

Getting SQL Rows For A Week
I have a database that uses two date fields for tracking information. The first field is for the addition of the record and the second is for the expiration.

I have a small section that I want to list records that will expire in the current week (or for that matter in the next 7 or 14 days). What is the syntax that I would use to call mySQL with to get that info.

Week Of The Month
I need to determine the week of the month (1-5) so I can rotate menus for a cafeteria.
Is the following, which I know prints the week rather than storing it, the simplest or easiest way to determine the week? PHP Code:

File Of The Week?
I wish to add an automated "file of the week" feature to a site for users to download.
I was having a little trouble explaining this.... So I ended up making these few points on the functions of the script I'm aiming for:

- The script finds the folder with the files for the current week. (If the download was a wallpaper, there would be files for different resolutions, and therefore more than one file.)

- Links are then made to the files.
- Every week, the links are updated for the new files for the current week.

I was thinking along the lines of putting the weekly files into folders named after timestamps and going from there... Is that the way to go? And how would it be done? I can't quite figure this out.

Printing Every Week
im trying to print a list of every Friday since a date defined. Let me try and explain. I want to define a date such as 2007-07-06 (which is a Friday) and then let php print each Friday since that date until today. For example, if the date defined was 2007-07-06 then it would print

2007-07-06
2007-07-13
2007-07-20
2007-07-27
2007-08-03
2007-09-14

But I want to also be able to format the date it outputs, so it might look like

Friday 06 July 2007
Friday 13 July 2007
Friday 20 July 2007
and so on.

Week Before Date
Im looking to get the date 7 days ago. I know how to do 7 days ahead:

$timeStamp = strtotime($oLastBatchDate->Last);
$timeStamp += 24 * 60 * 60 * 7;
$NextBatchDate = date("Y-m-d  H:i:s", $timeStamp);

However, does anyone know how to do 7 days back?

Date And Week
I am looking for a way to determine the week of the year if i have a date.i know that
date("W"); give me the week Number but not sure how to determine the week based on the date.

Day Of The Week Program
I am trying to write a program that will give me the day of the week without using the date function. I input the date and it's supposed to spit out the name of the day of the week. Here is what I have so far. I don't know quite what to do next. Code:

Date Of The First Day From A Given Week Number
I need some help to figure out the date of the first day in a given week number. Let's say that I pick week number 23, I want to retrive the day of that monday in week 23..

I've been searching the net for days without any result.

Datetime Within Past Week
I have a series of records in a database. When each record is stored,
the datetime is logged: $date = date("Y-m-d H:i:s");

Prior to adding a new record to the database, I want to run a query to
retrieve all of the records uploaded in the last 7 days. I thought it
would be easiest to:

Pseudo Code:
$newDate = $date - 7 days;
select * from TABLE where DATE $newDate;

Problem is I can't figure out how to subtract 7 days from $date and
convert that value to a valid datetime object.

Current Week Number
how I can split the month out into 5 weeks... then to have the week number printed and when the current week ends it will increment to the next week number. For example today is 3rd of July, therefore we are in week 1 of the month. Next week will be week two. I want it to go back to 1 at the start of the next month though.

Date Out Of Week Number?
I would need to get a date out of a week number, for example for week 52 the first date, 25/12. In my system the user inputs a week number, and then I would like to display a popup list of all seven dates for that week, for her to choose from. Is there a handy function to do this, or can you think of any way to achieve this?

Handling Week Number
I have been reviewing some calenders classes and have notice that if u
uses us written class with displays week number it ll by wrong for eu.
so to my question
how do you handle week numeration depenting on country? is there any
simple solutions for this?

Mysql WEEK() Function
In mysql WEEK() function it specify the number of week of a specific
date. For example January 02, 2006 will return a value of 2. Now my
problem is how could i be able to determine the range of that value in
a week like a value of 2 will be equal to January 1, 2006 - January 7,
2006.

309833 Web Views Last Week
This number seems about 30 times higher than normal for this group.

The group usually sees 10 times less traffic than the CakePHP group.

Month From Week Number?
Has anybody here ever made or seen a function which when passed year and week number in that year returns month ?

actually what I want is all records from db starting from six months back till now and group them by weeks, and some weeks may have no record so they won't appear in resultset. But I have to display zero against these weeks.

display has to be in form of Number of Records in Week # x of Month y e.g Number of Records in Week 2 x of Month Jan So my solution is to get records from db by this query:
.. where abs(Week(Now()) - Week(RecTime)) <= 26

this works ok but I don't have any idea of which month and week of month was 6 months ago.
So I decided to get week number and year of 6 months back and then write my function get month form this info.

How To Calculate The Day Of The Week By A Given Date.
I'm currently working on a (simple) calendar system which allows registered users to add an event to the calendar. The table EVENT stores info about the author, date and description of the event.

I then managed to output a list in which only events of this year are showed and are grouped together by months. And now I only need one more thing to complete the script. I want to output for every event on which day of the week it occurs (monday - sunday). I've looked around for tutorials but haven't found a basic one.

Date Function For Week Before
Im looking to get the date of a week before a certain date For example:

      $iLastDate = date("Y-m-d H:i:s ");
      $timeStamp = strtotime($iLastDate);
      $timeStamp + = 24 * 60 * 60 * 7;
      $NextBatchDate = date("Y-m-d  H:i:s", $timeStamp);

This is for a week ahead, how do I do a week before?

Week Ending Dates
When a user logs on, he should have a drop down selection box of week ending dates that would include any week ending dates that he hasn’t completed time for, only going back as far to a specified date and then also the current week he is within and up to 1 week forward. The week ending dates should always be on a Sunday. The table I have is as follows;

CREATE TABLE `techs_pay_weeks` (
  `tech_pay_week_id` int(11) NOT NULL auto_increment,
  `tech_pay_week_ending_date` date NOT NULL default '0000-00-00',
  `tech_id` int(11) NOT NULL default '0',
  `tech_pay_week_hours` float NOT NULL default '0',
  `tech_pay_week_amt` float NOT NULL default '0',
  `tech_pay_week_approved` tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (`tech_pay_week_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

The tech_id is held as a $_SESSION[userid] when he logs in. I understand how to advance a date, but not from a dynamic date that should always fall on a Sunday, and a current Sunday at that.

Constraint Using The Days Of The Week?
I am developing a property application where I have 5 members and only want 1 member a day to choose their property for the "property of week" section.

So I want to assign a day to each member.

Mem1 - Mondays
Mem2 - Tues
Mem3 - Wed etc..

Each member will have there own unique logon so if Mem1 logs in on Monday, they will have the "property of week" option avaliable to them. Mem2 will have it Tuesday and so on.

Work Out Day Of Week From Given Date
I'm using a date picker to choose a date. the format of the date entered into the textbox is yy/mm/dd

From this how can I work out the day of the week from the entered date? I need this as the first day has to be a sat, and if it isnt my form will tell the user to choose a saturday.

Is there a simple way of doing this?

How To Remove Entries In A DB That Are A Week Old?
I ahve a social network and I have a bulletin system, taht allows users to post bulletins that all their friedns can read... well anway, i dont want the bulletin to just sit there and take up DB space, how would i go about removing "bulletins" that are over a week old?

Automatic Display Of Events Each Week
I know how to display a list of upcoming events from a SQL database, but am wanting to display the events based on the date, eg. events happening this week only. Could someone tell me how to do this or point me in the right direction please?

Getting Day Of Week From User Defined Date?
is there a way to do this? e.g. i have three drop down boxes in html asking the user for day (1-31), month, year (2007 or 2008) i then have:

// get user input
$start_day = $_POST["start_day"];
$start_month = $_POST["start_month"];
$start_year = $_POST["start_year"];
//echo $start_year;

$the_date = $start_day . "/" . $start_month . "/" . $start_year; echo $the_date; say then i get an output as 13/10/2007 if the user enters that date, is there a way to get what day of the week this is?


Copyright © 2005-08 www.BigResource.com, All rights reserved