database_query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jr
Forum Commoner
Posts: 99
Joined: Mon Mar 07, 2005 3:25 pm

database_query

Post by Jr »

ok... I have a simple database query that looks for entrys that exactly match a date that is on a calendar. I want to set it up so i can repeat entrys (every year, week, etc.) but i dont know how to query 'part' of an entry in a db. Anyone want to help?
jammindice
Forum Newbie
Posts: 4
Joined: Fri Jun 10, 2005 12:20 pm
Location: MD, USA

Post by jammindice »

This is what i use to search through email addresses. You ARE using mysql i presume.

select * from mailbox where name like concat('%$search%') order by name

Thanks,
Shaun Mickey
270net Technologies
Systems Administrator
Jr
Forum Commoner
Posts: 99
Joined: Mon Mar 07, 2005 3:25 pm

Post by Jr »

ok, now what is the concat() function? how exactly does it work? I tried it and it didn't seem to work how i thought it would. Is there any way I can just do something like this:

Code: Select all

$date = "%-06-23";

$day_query_2	=	mysql_query( "SELECT * FROM calendar WHERE received='$date' LIMIT $limit" );
I basically want the year part of the date to be random but I dont know how to do that.
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

How about the DAY() and MONTH() functions?

Code: Select all

WHERE DAY(received) = 23 AND MONTH(received) = 6
Jr
Forum Commoner
Posts: 99
Joined: Mon Mar 07, 2005 3:25 pm

Post by Jr »

hmm... giving me a MySQL error? Did I put it in wrong? I removed the "DAY()" function and it works but doesn't when I remove "MONTH()" function...

Code: Select all

$day_query_2	=	mysql_query( "SELECT * FROM calendar WHERE MONTH(received)='$new_month_num' AND DAY(received)='$new_day' LIMIT $limit" );
Jr
Forum Commoner
Posts: 99
Joined: Mon Mar 07, 2005 3:25 pm

Post by Jr »

...figured it out DAYOFMONTH()... Thanks a lot for the help.
Post Reply