Welcome Guest, Not a member yet? Register   Sign In
Please help. Fill an array from database.
#11

[eluser]wiredesignz[/eluser]
All arrays have keys and values
Code:
array('something', 'else')  //PHP assigns numeric key and is represented as:

Array(
    [0] => 'something'    // 0 is the key for this item
    [1] => 'else'         // 1 is the key for this item
)

array('a_day' => 'monday', 'another_day' => 'tuesday') //User defined key is represented as:

Array(
    [a_day] => 'monday'           // a_day is the key for this item (also key 0)
    [another_day] => 'tuesday'    // another_day is the key for this item (also key 1)
)

Not to be rude, but you should really learn some PHP basics, http://www.php.net/arrays is a good place to start.
#12

[eluser]Tom Glover[/eluser]
As suggested above use FOR and WHILE Loops to split the data into the array. These functions are basic PHP but can create good effects, in CI they may be differently called but they still work the same.
#13

[eluser]cereal[/eluser]
@murphy
if you didn't solve it, with PHP5 you can do it this way:

Code:
<?php
    $dates = array();
    foreach($query->result() as $row)
    {
        $datetime = date_create($row->data);
        $day = date_format($datetime, 'j');
        $dates[$day] = base_url().'news/'.$row->id;
    }
    
    echo $this->calendar->generate('','',$dates);
?>

Note: it's important to use j in date_format() because the calendar can't use leading zeros.. bye Smile

P.S. I know it's an old thread but the solution can always be useful.. bye




Theme © iAndrew 2016 - Forum software by © MyBB