For Programmers: Free Programming Magazines  


Home > Archive > PHP on Windows > November 2004 > RE: [PHP-WIN] While loops to build an array









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE: [PHP-WIN] While loops to build an array
S.D.Price

2004-11-30, 4:00 pm


Hi thanks but this gives:

$days[date] =3D id;=20

What I need is a multidimensional array in the form

$days =3D array([date]=3D>array(id),)

Do you know how to do this?

thanks
Steve


-----Original Message-----
From: re_action [mailto:re_action@fromru.com]=20
Sent: 30 November 2004 17:10
To: php-windows@lists.php.net
Subject: Re: [PHP-WIN] While loops to build an array


Hello S.D.Price,

Your syntax is not correct, try this, instead:
if (mysql_num_rows($result3) > 0){
while ($row =3D mysql_fetch_array($result3)) {
$days[date(j,$row3['entry_date'])] =3D $row3['newsid'];
};
}
else {
echo "<p>The array has not been built.</p>";
};



SDP> Hi, I wonder if you could help. I am trying to build a php based=20
SDP> calendar for a news blog. The calendar should create hyperlinks=20
SDP> directly to a news story. However in order to do this I need to=20
SDP> create a $days array which takes the date value of the story=20
SDP> submitted and the id of the story and creates a dynamic link.

SDP> Howver I am finding it difficult to generate the array using a=20
SDP> while loop - do you know a better way?.


SDP> if (mysql_num_rows($result3) > 0) {=09
=09
SDP> $days =3D array( =20
SDP> while ($row =3D mysql_fetch_array($result3)) {
SDP> date(j,=20
SDP> $row3['entry_date'])=3D>array($row3['newsid']),;
SDP> } =09
SDP> );
=20
=20
SDP> }
=20
SDP> else { =20
SDP> echo "<p>The array has not been built.</p>";
=20
SDP> }
=20
SDP> echo generate_calendar($year, $month, $days);

SDP> Thanks

SDP> Steven





--=20
Best regards,
re_action mailto:re_action@fromru.com

--=20
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com