Jump to content

Array Question


adam291086

Recommended Posts

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

Link to comment
Share on other sites

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>"; 
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.