Membership is FREE, giving all registered users unlimited access to every Acorn Domains feature, resource, and tool! Optional membership upgrades unlock exclusive benefits like profile signatures with links, banner placements, appearances in the weekly newsletter, and much more - customized to your membership level!

PHP help please

Status
Not open for further replies.

Admin

Administrator
Staff member
Joined
Jun 14, 2004
Posts
11,076
Reaction score
962
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
 
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:
SELECT * FROM table WHERE DATE_FORMAT( datetime_field, '%Y-%m-%d' ) = DATE_SUB( CURDATE(), INTERVAL 2 DAY )
 
In that case could try:

HTML:
SELECT * FROM table WHERE FROM_UNIXTIME( fieldname, '%Y-%m-%d' ) > date_SUB( CURDATE(), INTERVAL 2 DAY )
 
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...
 
In the auctions i only want the "view bids" to show if the auction has bids, how do I do that?

I also want to link (join) to another table to get the number of bids...

thanks

Admin
 
hi admin,

you probably already know, but i think maybe,

IF bidcount row >= 1 {

show }

else {
"be the first to bid" (whatever)
}

i could give a better answer if i could see the code, table/feild names.

pm me if you want me to have a "proper bash" tomo.
 
hi admin,

you probably already know, but i think maybe,

IF bidcount row >= 1 {

show }

else {
"be the first to bid" (whatever)
}

i could give a better answer if i could see the code, table/feild names.

pm me if you want me to have a "proper bash" tomo.
I'm already using the IF and ELSE to alternate the row colours. How do I do both?
 
Hi admin,

Im dont know the names of your rows or excatly how you've done the if/elses for the row colours, but maybe something like this,



your IF (condition for row colour) {

your if code for row colour;

/* new if stament */ IF (yourbidcount.row >= 1) {

print ("<a href=\"linkToBidPage/\">view bids</a> ");

}



else {

print("be the first to bid");

}

}

your else {

your else code for the row colour

/* new if stament */ IF (yourbidcount.row >= 1) {

print ("<a href=\"linkToBidPage/\">view bids</a> ");

}



else {

print("be the first to bid");

}

}


}


Its a bit messy, but should work.
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Members online

No members online now.

Premium Members

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
      There are no messages in the current room.
      Top Bottom