Re: While loops to build an array

From: Date: Tue, 30 Nov 2004 17:09:39 +0000
Subject: Re: While loops to build an array
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-25093@lists.php.net to get a copy of this message
Hello S.D.Price, Your syntax is not correct, try this, instead: if (mysql_num_rows($result3) > 0){ while ($row = mysql_fetch_array($result3)) { $days[date(j,$row3['entry_date'])] = $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 SDP> calendar for a news blog. The calendar should create hyperlinks directly SDP> to a news story. However in order to do this I need to create a $days SDP> array which takes the date value of the story submitted and the id of SDP> the story and creates a dynamic link. SDP> Howver I am finding it difficult to generate the array using a while SDP> loop - do you know a better way?. SDP> if (mysql_num_rows($result3) > 0) { SDP> $days = array( SDP> while ($row = mysql_fetch_array($result3)) { SDP> date(j, SDP> $row3['entry_date'])=>array($row3['newsid']),; SDP> } SDP> ); SDP> } SDP> else { SDP> echo "<p>The array has not been built.</p>"; SDP> } SDP> echo generate_calendar($year, $month, $days); SDP> Thanks SDP> Steven -- Best regards, re_action mailto:re_action@fromru.com

« previous php.windows (#25093) next »