RSS Feed
------=_NextPart_000_0035_01CBC089.CF0895D0
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
I have a question about the mySQL query below. The purpose is to find =
the last 15 days Bible reading for an RSS feed.
In the table each day=E2=80=99s reading is assigned the day # in the =
year (between 1 and 365). But if the query is ran on January 6th, for =
example, it will only find 6 rows in the result. Is there a fancy way =
to ensure a total of 15 rows are retrieved, even if some of the rows =
from the end of the year (days 350 to 365) are being displayed, so it is =
like a loop? (I have a record in the table for day 366 for =
=E2=80=98leap year=E2=80=99 that says the Bible reading starts again =
tomorrow, for when it is needed every 4th year)
Ron
=3D=3D=3D
$day_of_year =3D getdate();
#add 1 because yday starts at 0
$day_of_year =3D $day_of_year[yday] + 1;
$query=3D"SELECT * FROM =
`$database1`.`friends_of_the_ministry_Bible_reading_plans` WHERE `plan` =
=3D1 AND `day` <=3D $day_of_year ORDER BY `day` DESC LIMIT 15";
=3D=3D=3D
The Verse of the Day
=E2=80=9CEncouragement from God=E2=80=99s Word=E2=80=9D
http://www.TheVerseOfTheDay.info
------=_NextPart_000_0035_01CBC089.CF0895D0--
Re: RSS Feed
On Sun, Jan 30, 2011 at 2:27 PM, Ron Piggott
<ron.piggott [at] actsministries.org> wrote:
>
> I have a question about the mySQL query below. =A0The purpose is to find =
the last 15 days Bible reading for an RSS feed.
>
> In the table each day=92s reading is assigned the day # in the year (betw=
een 1 and 365). =A0But if the query is ran on January 6th, for example, it =
will only find 6 rows in the result. =A0Is there a fancy way to ensure a to=
tal of 15 rows are retrieved, even if some of the rows from the end of the =
year (days 350 to 365) are being displayed, so it is like a loop? =A0(I hav=
e a record in the table for day 366 for =91leap year=92 that says the Bible=
reading starts again tomorrow, for when it is needed every 4th year)
>
> Ron
>
> =3D=3D=3D
>
> $day_of_year =3D getdate();
>
> #add 1 because yday starts at 0
> $day_of_year =3D $day_of_year[yday] + 1;
>
> $query=3D"SELECT * FROM `$database1`.`friends_of_the_ministry_Bible_readi=
ng_plans` WHERE `plan` =3D1 AND `day` <=3D $day_of_year ORDER BY `day` DESC=
LIMIT 15";
>
> =3D=3D=3D
>
> The Verse of the Day
> =93Encouragement from God=92s Word=94
> http://www.TheVerseOfTheDay.info
>
Ron,
Why not do a mktime for -15 days...that should cover the calendar back
into last year
www.php.net/mktime
--
Bastien
Cat, the other other white meat
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: RSS Feed
Bastien I have been wondering about this approach this afternoon, but I
don't know how to do it. What is throwing me off is the structure of the
database. There is no year in it. Only the column "day" is a number from 1
to 366 (See table structure, below)
I get that you are saying though. If it is between January 1st and 15th the
remaining records are in December of the previous year.
CREATE TABLE IF NOT EXISTS `friends_of_the_ministry_Bible_reading_plans` (
`reference` int(4) NOT NULL AUTO_INCREMENT,
`plan` int(2) NOT NULL DEFAULT '0',
`day` int(4) NOT NULL DEFAULT '0',
`assigned_reading` varchar(65) NOT NULL DEFAULT '',
`content_summary` varchar(500) NOT NULL,
PRIMARY KEY (`reference`)
)
Are you able to offer me some more help with this table structure?
Ron
The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info
-----Original Message-----
From: Bastien Koert
Sent: Sunday, January 30, 2011 4:10 PM
To: Ron Piggott
Cc: php-db [at] lists.php.net
Subject: Re: [PHP-DB] RSS Feed
On Sun, Jan 30, 2011 at 2:27 PM, Ron Piggott
<ron.piggott [at] actsministries.org> wrote:
>
> I have a question about the mySQL query below. The purpose is to find the
> last 15 days Bible reading for an RSS feed.
>
> In the table each day’s reading is assigned the day # in the year (between
> 1 and 365). But if the query is ran on January 6th, for example, it will
> only find 6 rows in the result. Is there a fancy way to ensure a total of
> 15 rows are retrieved, even if some of the rows from the end of the year
> (days 350 to 365) are being displayed, so it is like a loop? (I have a
> record in the table for day 366 for ‘leap year’ that says the Bible
> reading starts again tomorrow, for when it is needed every 4th year)
>
> Ron
>
> ===
>
> $day_of_year = getdate();
>
> #add 1 because yday starts at 0
> $day_of_year = $day_of_year[yday] + 1;
>
> $query="SELECT * FROM
> `$database1`.`friends_of_the_ministry_Bible_reading_plans` WHERE `plan` =1
> AND `day` <= $day_of_year ORDER BY `day` DESC LIMIT 15";
>
> ===
>
> The Verse of the Day
> “Encouragement from God’s Word”
> http://www.TheVerseOfTheDay.info
>
Ron,
Why not do a mktime for -15 days...that should cover the calendar back
into last year
www.php.net/mktime
--
Bastien
Cat, the other other white meat
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php