hi,
Shown below is the PHP code to obtain the value for each date in the
corresponding date range.And with I've attached the MYSQL Database
Table.Please Have a look.I've tried to convert this code to rails but
not yet succeeded.Please let me know if you can do....
<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("dgrid_development",$con);
$sql=mysql_query("select * from events");
while($row=mysql_fetch_array($sql))
{
$date_array = date_range($row["when"],$row["to"]);
$txt='('.$row["what"].'-'.$row["color"].')';
$arrayMixed[]= array_fill_keys($date_array, $txt);
}
function date_range($sd,$ed)
{
$tmp = array();
$sdu = strtotime($sd);
$edu = strtotime($ed);
while ($sdu <= $edu)
{
$tmp[] = date('Y-m-d',$sdu);
$sdu = strtotime('+1 day',$sdu);
}
return ($tmp);
}
foreach($arrayMixed as $final)
{
foreach($final as $key=>$value)
{
$group[$key].=$value;
}
}
print'<pre>';
print_r($group);
print '</pre>';
?>
Thanks in Advance.
cheers,
Shankar.
Attachments:
http://www.ruby-forum.com/attachment/3262/events.sql
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---