Query Problem - Query and Rand help

Hey guys, i’m back. i’ve had a small break from learning php and it has been the death of me.

I am working on a small project to learn and i cannot get it working. doing a small fake dvd website, which will allow me to edit movies/members/display movie info.

I am having trouble writing a query for the front page. Here is the problem: My database has a table, each row with an auto id. It also has a rental period id. I wish to write a script to select all rows with a rental period id of “3” and then add them to an array, select 3 of them from random and display them.

Here is what I have so far, but i am getting resource id’s


<?php
                    $query = "SELECT `movie_id` FROM `movies_table` WHERE `rentalperiod_id` = '3' ";
                    $result = mysql_query($query);
                    print $result;
                    //$num = mysql_num_rows($result);
                    //if ($num > 0) 
                    {
                        $id_array = array();
                        while ($row = mysql_fetch_assoc($result)) 
                        {
                            $id_array []=$row["movie_id"];
                        }
                        $query = "SELECT `movie_url` FROM `movies_table` WHERE `movie_id`=".$id_array[rand(0, (count    ($id_array)-1))];
                        $result = mysql_query($query);
                        $row = mysql_fetch_assoc($result);

                    }