Page 1 of 1

PHP code not working for my "Movies" Section

Posted: Fri Mar 14, 2008 6:24 pm
by motleycrewl
I'm in need of a wizards assistance. The problem I have is with the PHP script for the "movies / concerts / events" tabbed section on this website: http://universitycenters.ucsd.edu/new2/index.php . Now right off the bat, I dont have access to the MYSQL tables so that's super inhibiting. I have access to the CRUD pages where I can view, edit, and add new rows but I dont have the field names etc. like I would via phpMyAdmin or something. Anyways, my problem is that I can't get the rollover function for the movie posters working (ie. rollover the name of a movie and its poster pops-up to the right) and I can't get the "Watch Trailer Now" button working: it simply takes me to the directory where all the trailers are but doesn't open the trailer I've selected. I've tinkered with it a fair amount but most of this PHP is really beyond me and I need help from a master.

Below is the code from the include file for the movies section called 'mce-movies':

Code: Select all

$result = mysql_query($sql);
$count = 0;
print "<div class='mce-data'>";
$poster_images = array();
$poster_video = array();
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
   if ($count % 2 == 1)
      print("\n<div class=\"odd\">");
   else
      print("\n<div class=\"even\">");
   if ($row[4] == "Movie"){
      $sql = "SELECT poster FROM movies WHERE id=" . $row[0];
      $result_movie = mysql_query($sql);
      $row_movie = mysql_fetch_array($result_movie, MYSQL_NUM);
      $poster_images[$count] = $posters_dir . $row_movie[0];
     
   }
   else{ //not a movie to and need to set image
      $poster_images[$count] = $categories_dir . $categories_imgs[$row[4]];
   }
   
   
   // Cut lengthy movie titles
   $movieTitle =  $row[3];
   $length = 30;
   $replacement = '…';
   
    if (strlen($movieTitle) > $length)
    {
        $output  = substr($movieTitle, 0, $length - 3);
        $output .= $replacement;
        $movieTitle = $output;
    }
    else
    {
         $movieTitle = $movieTitle;
    }
         
   print ("&nbsp;Monday $row[1]/$row[2]</div><div style='float:left;margin:0 5px 0 10px;'>6pm:</div> <div style=' float:left; width:150px; border:0px solid #F00;
   margin:0 0 0 5px;'><a href=\"#\" onmouseover=\"image_swap('$count') \"> $movieTitle [/url]</div>
 
");
   print("\n");
   $count++;
 }
 print "</div>";
 ?>


And this is the code for the homepage part of the movie section:

Code: Select all

<div class="movies">                             
          <h2>This Week's Movies</h2><?php include ("includes/mce-movies.php"); ?>
         <div class="poster"><img name="event_image" alt="movie poster" src="../events_beta/posters/<?php echo $row_movie[0] ?>" height="133" width="80" />
 
         <a href="../events_beta/movie_clips/<?php echo $row_movie[1] ?>">Watch the Trailer[/url]</div>
         <div style="clear:both;"></div>     
        </div>

Re: PHP code not working for my "Movies" Section

Posted: Fri Mar 14, 2008 11:11 pm
by yacahuma
but do you know the fields, the database schema? I hate to sound obvious , but you url in the watch trailker is wrong. You need to get the correct path from the same place you get the image.

if you can connect to the database you can get all the info you need.

Re: PHP code not working for my "Movies" Section

Posted: Sat Mar 15, 2008 4:39 pm
by motleycrewl
OK, im an idiot :oops: , heres the java script function for the rollovers :

Code: Select all

<!-- mce poster rollover script -->
<script type="text/javascript">
        var _i = new Image();   _i.src="../events_beta/posters/davinci.jpg";
        
        var img_1 = new Image();    img_1.src="<?php echo $poster_images[0] ?>";
        var img_2 = new Image();    img_2.src="../events_beta/posters/blank.gif";
        var img_3 = new Image();    img_3.src="../events_beta/posters/blank.gif";
        var img_4 = new Image();    img_4.src="../events_beta/posters/blank.gif";
        var img_5 = new Image();    img_5.src="<?php echo $poster_images[4] ?>";
        
        function image_swap( _img)
        {   
            if ( _img == 0)
                document.images["event_image"].src = img_1.src;
            if ( _img == 1)
                document.images["event_image"].src = img_2.src;
            if ( _img == 2)
                document.images["event_image"].src = img_3.src;
            if ( _img == 3)
                document.images["event_image"].src = img_4.src;
            if ( _img == 4)
                document.images["event_image"].src = img_5.src;
        }
    </script>
and heres the small PHP script that references the image directory:

Code: Select all

<?php
$category_dir = "../events_beta/categories/";  // Define category directory
$posters_dir = "../events_beta/posters/";      // Define poster image directory
$video_dir = "../events_beta/video/";  //Define video trailer directory
//$categories_imgs["Art Reception"] = $category_dir . "art_reception.jpg"; //id: 1 - Art Reception
?>

Re: PHP code not working for my "Movies" Section

Posted: Sun Mar 16, 2008 12:04 am
by RobertGonzalez
I cannot access your URL. Is it still up?

Is this a problem with the PHP or with the javascript? What does the source show you when you view source in your browser? Do you use the Firebug extension in Firefox for troubleshooting? Does the javascript console give you any warnings/errors if you are not using Firebug?