Buy Sell Discuss UK Domain Names at AcornDomains.co.uk Domain Monster Domain Name Registration

Today's Drop Dates are: 19-02-2012 or 26-02-2012   All times are GMT. The time now is 12:44:47 PM.
Domain Name Sales Domain Software Calculate UK Domain Drop Dates Domain Registration NameDrive Domain Parking Subscribe to our Domains For Sale newsletter
Go Back   Domain Forum Acorn Domains Buy Sell Auction UK Domains > Website Design and Promotion > Website Design > Scripts and Coding
Connect with Facebook

Scripts and Coding PHP, MySQL, scripts

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 24-04-2011, 09:58:40 PM     #1 (permalink)
Administrator
 
admin's Avatar
 
Join Date: Jun 2004
Posts: 8,601
admin has disabled reputation

Script PHP help please

Hi all,

I am trying to get records from a DB where the date in a field is todays date, or the next day's date:

Code:
`fieldname` > date_SUB(CURdate(), INTERVAL 2 DAY)
doesn't work.

Any help please?

Thanks

Admin
admin is offline  
Old 24-04-2011, 11:19:08 PM     #2 (permalink)
Member
 
Join Date: Apr 2010
Location: Buenos Aires
Posts: 83
JDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond repute

Is the format of the date field in the DB table DATETIME instead of DATE?

DATETIME = YYYY-MM-DD HH:MM:SS
DATE = YYYY-MM-DD

Because CURDATE() returns the date in the format YYYY-MM-DD, which means if the date field was DATETIME then it would not match (the hours, mins, secs throwing it off) .

If so, you can use DATE_FORMAT to change the value extracted from the DATETIME field. For example:

PHP Code:
SELECT FROM table WHERE DATE_FORMATdatetime_field'%Y-%m-%d' ) = DATE_SUBCURDATE(), INTERVAL 2 DAY 
JDubya is offline  
Old 24-04-2011, 11:57:25 PM     #3 (permalink)
Administrator
 
admin's Avatar
 
Join Date: Jun 2004
Posts: 8,601
admin has disabled reputation

Thanks for the suggestion.

The field type is "int(10)" and shows a string of numbers which I assume is a Unix format date string.

Admin
admin is offline  
Old 25-04-2011, 12:09:53 AM     #4 (permalink)
Member
 
Join Date: Apr 2010
Location: Buenos Aires
Posts: 83
JDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond repute

In that case could try:

HTML Code:
SELECT * FROM table WHERE FROM_UNIXTIME( fieldname, '%Y-%m-%d' ) > date_SUB( CURDATE(), INTERVAL 2 DAY )
JDubya is offline  
Old 25-04-2011, 12:16:28 AM     #5 (permalink)
Administrator
 
admin's Avatar
 
Join Date: Jun 2004
Posts: 8,601
admin has disabled reputation

Didn't work.. no errors but no effect on SELECT statement results either
admin is offline  
Old 25-04-2011, 12:26:52 AM     #6 (permalink)
Member
 
Join Date: Apr 2010
Location: Buenos Aires
Posts: 83
JDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond repute

Quote:
SELECT fieldname, FROM_UNIXTIME( fieldname, '%Y-%m-%d' ), CURDATE(), DATE_SUB( CURDATE(), INTERVAL 2 DAY )
FROM table
LIMIT 5
Paste in the results of the above query here - might make it easier to spot something...
JDubya is offline  
Old 25-04-2011, 03:13:13 PM     #7 (permalink)
Administrator
 
admin's Avatar
 
Join Date: Jun 2004
Posts: 8,601
admin has disabled reputation

It just selects all the records instead of just the ones with 2 days difference from today's date.
admin is offline  
Old 26-04-2011, 08:04:03 PM     #8 (permalink)
Administrator
 
admin's Avatar
 
Join Date: Jun 2004
Posts: 8,601
admin has disabled reputation

Got that sorted after playing about for hours.

Now I'm build a PHP to RSS script, how do I add a URL link in the following line:

Code:
$rssfeed .= '<link>' . $classifiedid . '</link>';
so link to http://www.acorndomains.co.uk/vbclas....php?do=ad&id=[$classifiedid field here]

Thanks

Admin
admin is offline  
Old 26-04-2011, 08:13:07 PM     #9 (permalink)

 
Join Date: Feb 2011
Location: Gosport - UK
Posts: 518
seemly has a reputation beyond reputeseemly has a reputation beyond reputeseemly has a reputation beyond reputeseemly has a reputation beyond reputeseemly has a reputation beyond reputeseemly has a reputation beyond reputeseemly has a reputation beyond reputeseemly has a reputation beyond reputeseemly has a reputation beyond reputeseemly has a reputation beyond reputeseemly has a reputation beyond repute

admin sorted code anyway. =)

Last edited by seemly; 26-04-2011 at 08:18:25 PM. Reason: Admin sorted code himself
seemly is online now  
Old 26-04-2011, 08:16:42 PM     #10 (permalink)
Administrator
 
admin's Avatar
 
Join Date: Jun 2004
Posts: 8,601
admin has disabled reputation

RSS - Admin Only Please

Never mind fixed it, needed to use the "htmlentities" tag.

Acorn forum auctions now has an RSS feed :

http://www.acorndomains.co.uk/auctions-rss.php
admin is offline  
Closed Thread



Bookmarks

Tags
php help please

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Domain Name Community Replies Last Post
Experienced freelance developer available (PHP, MySQL, Wordpress, feeds, APIs, etc. MartinWood Scripts and Coding 0 06-09-2010 11:33:05 AM
Which PHP framework monaghan Scripts and Coding 6 22-07-2010 08:31:56 PM
PHP include in a Smarty Template admin Scripts and Coding 1 13-05-2008 06:37:26 AM

75% off Domains at Network Solutions®.


All times are GMT. The time now is 12:44:47 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.0 RC 2
All content on Acorn Domains is member generated and is not moderated before posting. All content is viewed and used by you at your own risk and AD does not warrant the accuracy or reliability of any of the information. The views expressed are those of the individual contributors and not necessarily those of AD. Please contact us to report any issues or send a PM to "Admin".