ayaycaptainchris Posted May 31, 2006 Share Posted May 31, 2006 I am trying to modify a premade php calendar that i have found, but cant seem to make it work.i have been trying for days to achieve this, but i have failed.basically, the premade php calendar has the code:[code]$days = array( 2=>array('/weblog/archive/2004/Jan/02','linked-day'), 3=>array('/weblog/archive/2004/Jan/03','linked-day'), 8=>array('/weblog/archive/2004/Jan/08','linked-day'), 22=>array('/weblog/archive/2004/Jan/22','linked-day'),); [/code]I want to chagne it to something that accesses the database. I have a table called "calendar" in my database[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]DATE MONTH LINK EVENT3 May [a href=\"http://www.3.com\" target=\"_blank\"]http://www.3.com[/a] Test4 May [a href=\"http://www.4.com\" target=\"_blank\"]http://www.4.com[/a] Test 25 May [a href=\"http://www.5.com\" target=\"_blank\"]http://www.5.com[/a] Test 36 May [a href=\"http://www.6.com\" target=\"_blank\"]http://www.6.com[/a] Test 4[/quote]and i want it to transform to[code]$sql = mysql_query("SELECT date, month, link, event FROM calendar where month='May'");$row = mysql_fetch_array($sql);$date = $row['date'];$month = $row['month'];$link = $row['link'];$event = $row['event'];$days = array( $date=>array('$link', '$event'),); [/code]it's not working. can someone please help me.basically, it should end up like[code]$days = array( 3=>array('http://www.3.com','Test'), 4=>array('http://www.4.com','Test 2'), 5=>array('http://www.5.com','Test 3'), 6=>array('http://www.6.com','Test 4'),); [/code] Quote Link to comment https://forums.phpfreaks.com/topic/10827-array-problem/ Share on other sites More sharing options...
poirot Posted May 31, 2006 Share Posted May 31, 2006 This should do the job:[code]$sql = mysql_query("SELECT date, month, link, event FROM calendar WHERE month='May'");while ($row = mysql_fetch_array($sql)) { $date = $row['date']; $month = $row['month']; $link = $row['link']; $event = $row['event']; $days[$date] = array($link, $event);}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10827-array-problem/#findComment-40578 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.