note 75320 added to ref.array

From: Date: Wed, 23 May 2007 18:28:52 +0000
Subject: note 75320 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-126853@lists.php.net to get a copy of this message
Hello guys! **You guys are my last solution please HELP!** I am having dificulty with the array() function: I am trying to populate an array from an MySQL quary and its not going to good :( (btw, a am trying to make an event/calendar script) the problem is with the $days variable. The manual way this should be set is as an array as follows: <?PHP $days = array ( 2=>array('#link','linked-day'), 20=>array('#link','linked-day'), ); ?> ... 2 & 20 being the dates in the month on wich i have an event This will later help in generating the calendar: <?PHP echo generate_calendar($year, $month, $days, 3, '#Luna', 0, $pn); ?> **1st try: <?PHP $result = mysql_query("SELECT * FROM events WHERE month='$month' AND year='$year'") or die ("Could not read data because ".mysql_error()); $days = array(); while ($qry = mysql_fetch_array($result)) { days[] = $qry[day]=> array ('#link', 'linked-day'); } ?> **2nd try: <?PHP $result = mysql_query("SELECT * FROM events WHERE month='$month' AND year='$year'") or die ("Could not read data because ".mysql_error()); while ($qry = mysql_fetch_array($result)) { $events.="$qry[day]=>array('#link', 'linked-day')"; } $days = array($events); ?> **3rd try: <?PHP $result = mysql_query("SELECT * FROM events WHERE month='$month' AND year='$year'") or die ("Could not read data because ".mysql_error()); $days = array(); while ($qry = mysql_fetch_array($result)) { array_push($days, $day);} } ?> And several other trys :sigh: I'd line to mention that in al examples, when i used print_r($days) or echo"$days"; the printout was OK but the generate_calendar() function didn't like it and didn't display any liked days. Please HELP! Thanks in advance! ---- Server IP: 69.147.83.197 Probable Submitter: 86.55.147.135 ---- Manual Page -- http://www.php.net/manual/en/ref.array.php Edit -- https://master.php.net/note/edit/75320 Del: integrated -- https://master.php.net/note/delete/75320/integrated Del: useless -- https://master.php.net/note/delete/75320/useless Del: bad code -- https://master.php.net/note/delete/75320/bad+code Del: spam -- https://master.php.net/note/delete/75320/spam Del: non-english -- https://master.php.net/note/delete/75320/non-english Del: in docs -- https://master.php.net/note/delete/75320/in+docs Del: other reasons-- https://master.php.net/note/delete/75320 Reject -- https://master.php.net/note/reject/75320 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#126853) next »