2009-10-20 60 views
0

我已經嘗試了所有我能想到的最後兩天。我真的迷失了。我需要根據我的數據庫來改變這行代碼。我已經嘗試了所有可以在php.net和許多論壇上找到的東西。數組中的數組PHP SQL

$ Myday =>陣列( '/的index.php?天= $ Myday &年= $ MYyear', '聯日'),

任何意見或幫助將非常appericated

 

$SQL = "SELECT * FROM DATE_BOOK'"; 
$result = mysql_query($SQL); 
while($row = mysql_fetch_array($result)) { 
    $agenda_id = $row["agenda_id"]; 
    $MYyear = $row["agenda_year"]; 
    $Myday = $row["agenda_day"]; 
    $agenda_month = $row["agenda_month"]; } 

    $days = array( 
     $Myday=>array('/index.php?day=$Myday&year=$MYyear','linked-day'), 
     $Myday=>array('/index.php?day=$Myday&year=$MYyear','linked-day')); 

    echo generate_calendar(2009, 1, $days, 3, '/weblog/archive/2004/Jan'); 
 

回答

2

你想這一點邊的循環:

$days = array(); 

這while循環中:

$days[$Myday] = array('/index.php?day=$Myday&year=$MYyear','linked-day'); 

你的循環實際上並沒有添加到你的數組中,它只是分配了一堆無論如何被重寫的變量。

+0

有趣的是,我看過簡單的選項。我認爲我需要使用foreach來做到這一點。非常感謝。 – 2009-10-20 01:25:02

0

對於其他人試圖讓http://keithdevens.com/software/php_calendar在這裏工作是簡單的代碼。當試圖找出答案時,我看到很多正在尋找答案的人。

$xgenda_real_date = date("m/d/Y"); 
$xgenda_month = date("m"); 
$xgenda_day = date("d"); 
$xgenda_year = date("Y"); 

$days = array(); 

$query = "SELECT * FROM DATE_BOOK"; 
$result = mysql_query($query); 
while($row = mysql_fetch_array($result)) { 
    $Myday = $row["agenda_day"]; 
    $agenda_id = $row["agenda_id"]; 
    $agenda_year = $row["agenda_year"]; 
    $agenda_month = $row["agenda_month"]; 

    $days[$Myday] = array("/index.php?day=$Myday&year=$MYyear",'linked-day'); 
} 

echo generate_calendar($xgenda_year, $xgenda_month, $days, 3,'index.php?page_id=$page_id', $pn); 

echo "<p>$xgenda_real_date"; 
+0

這不正是Tim回答的嗎? – random 2009-10-20 01:34:50