You are here: Re: question about sql query « All PHP « IT news, forums, messages
Re: question about sql query

Posted by gerg on 12/22/05 11:41

gerg wrote:
> This is beyond my scope of knowledge at this point. I've got two
> databases, one with "user info", the other with "events".
>
> I'm working on a calendar that at this point selects all user posted
> "events" from the events db.
>
> The query is this:
>
> $sql="SELECT * FROM `calendar` WHERE `month`=\"$month\" AND
> `year`=\"$year\" ORDER BY `day` asc";
>
> This works great.
>
> Now I want to add into this query, a selection of the "user info"
> birthdates and mix them in with the results of the query.
>
> So if I had two events, Jan 1 and Jan 3, and a birthday on Jan 2, the
> results would be:
>
> Jan 1. Event
> Jan 2. Birthday
> Jan 3. Event
>
> How could I modify the sql query below to accomplish this?
>
> $sql="SELECT * FROM `calendar` WHERE `month`=\"$month\" AND
> `year`=\"$year\" ORDER BY `day` asc";
>
> Thanks in advance.
>
> Greg
I would like to change my question if I may:

Now i've got two tables on one database. "Birthday" and "Events".

My sql query to pull the data out of events is this:


$sql="SELECT * FROM `calendar` WHERE `month`=\"$month\" AND
`year`=\"$year\" ORDER BY `day` asc";


Now In my calendar I'm feeding the month and year variables through
$_GET, so that my users can view future months.IE month=march&year=2020
would allow users to view events posted for March of 2020.

However, the above query will not work for the "birthday" table due to
the fact that the "year" column in the birthday table is set to the year
they were born, and not the "year" being fed in the $_GET. So, i'll
never have a match unless it's the birth year. I need to be able to
select the birthdays every year under the specified birth month. Am I
making any sense at this point? Thanks to anyone that got this far and
can help me out.

Thanks again, Greg

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация