adam291086 Posted December 7, 2007 Share Posted December 7, 2007 ok i have set my array up for example, $adam= array(); while($row = mysql_fetch_array($result)) { $adam[$row['Day']] = $row['Event Details']; } as the array key is set to $row['days'] what happens if there is the same number? How do you echo both bits of information? Quote Link to comment Share on other sites More sharing options...
adam291086 Posted December 7, 2007 Author Share Posted December 7, 2007 i take it this is not possible??? If not any sggestions on how to get around it? Quote Link to comment Share on other sites More sharing options...
thefortrees Posted December 7, 2007 Share Posted December 7, 2007 ??? I don't really understand what you are asking. If the array key is the same as one that exists already, the value stored in the array will be overwritten with the new value. What bits of information do you want to echo? Just use 'echo'. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 7, 2007 Share Posted December 7, 2007 You need to add another array to make it unique. adam[row][day][event] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 7, 2007 Share Posted December 7, 2007 You can do something like this: <?php $adam= array(); while($row = mysql_fetch_array($result)) { if (isset($adam[$row['Day']])) { $tmp = explode('~',$adam[$row['Day']]); $tmp[] = $row['Event Details']; $adam[$row['Day']] = implode('~',$tmp); } else $adam[$row['Day']] = $row['Event Details']; } ?> For this to work, you have to pick a character that is not used in the $row['Event Details'] string to be the delimiter. Ken Quote Link to comment Share on other sites More sharing options...
adam291086 Posted December 7, 2007 Author Share Posted December 7, 2007 ok, thanks ken i get the idea. Therefore i have added ID to the database for each event. Therefore i have made each event individual. But when i echo the array i just get [0] can anyone see why This is where i set up the array $arrDays = array(); $arrEvent = array(); while($row = mysql_fetch_array($result)) { $id = $row['ID']; $arrDays[] = $row['Day'] ; $Month = $row['Month'] ; $Year = $row['Year'] ; $arrEvent[$row['Day'].$row['ID']] = $row['Event Details']; This is when i echo the array (in_array($counter,$arrDays)) { for ($i=$counter;$i<=$counter;$i++) { for ($a=0;$a<=$ID;$a++) { echo "<td><a href=#>$counter<span>$arrEvent[$i][$a]</span></td></a>"; } } } else { echo "<td>$counter</td>"; } Quote Link to comment 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.