RE: While loops to build an array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi thanks but this gives:

$days[date] = id; 

What I need is a multidimensional array in the form

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

Do you know how to do this?

thanks
Steve


-----Original Message-----
From: re_action [mailto:re_action@xxxxxxxxxx] 
Sent: 30 November 2004 17:10
To: php-windows@xxxxxxxxxxxxx
Subject: Re:  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 = 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 
SDP> directly to a news story. However in order to do this I need to 
SDP> create a $days array which takes the date value of the story 
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 
SDP> while 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@xxxxxxxxxx

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

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



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux