RE: Re: HTML layout and arrays (WAS : Brain not working, helpneeded :-). .

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Date: Mon, 29 Aug 2005 07:46:52 -0500
Message-ID: <67C5DCA3F0C94E4186175E682FBB36230B3BAC93@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
From: "Norland, Martin" <Martin.Norland@xxxxxxxxxx>
To: <php-db@xxxxxxxxxxxxx>
Reply-To: <php-db@xxxxxxxxxxxxx>
Subject: RE: Re: HTML layout and arrays (WAS : Brain not working, helpneeded :-). .

>-----Original Message-----
>From: Neil Smith [MVP, Digital media]
[mailto:php@xxxxxxxxxxxxxxxxxxxxxxxx]
>
>The variable type you need is called an array, it has numerical indexes
:
>In PHP you can just omit the index and it'll be automatically
>auto-incremented from zero, so there's no need to maintain a counter :
>
>$videos=array();
>while ($row = mysql_fetch_array($sql_result)) {
>    $videos[]["id"] = $row["id"];
>    $videos[]["video_link"] = $row["video_link"];
>    $videos[]["video_thumbnail"] = $row["video_thumbname"];
>    $videos[]["video_title"] = $row["video_title"];
>    $videos[]["video_description"] = $row["video_description"];
>
>};
>
>print_r($videos);
>
[snip]

You either want to be putting a $count in there, or assigning it all in
one go, otherwise you're left with:
        $videos[0] == $row["id"]
        $videos[1] == $row["video_link"]
        etc.

Yeah LOL, /me slaps forehead !
It's been a long weekend, the correct solution is as Martin stated below :


while ($row = mysql_fetch_array($sql_result) {
        $videos[] = array(
                'id' => $row['id'],
                'video_link' => $row['video_link'],
                'video_thumbnail' => $row['video_thumbname'],
                'video_title' => $row['video_title'],
                'video_description' => $row['video_description'],
        );
}


Cheers - Neil
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux