Date: Mon, 29 Aug 2005 07:46:52 -0500
Message-ID: <[EMAIL PROTECTED]>
From: "Norland, Martin" <[EMAIL PROTECTED]>
To: <php-db@lists.php.net>
Reply-To: <php-db@lists.php.net>
Subject: RE: [PHP-DB] Re: HTML layout and arrays (WAS : Brain not working, helpneeded :-). .


>-----Original Message-----
>From: Neil Smith [MVP, Digital media]
[mailto:[EMAIL PROTECTED]
>
>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

Reply via email to