Paulio Posted July 4, 2010 Share Posted July 4, 2010 Hey, i have a PHP script on my ReadyNas Duo that basically displays a list of movie data sorted on the unit, then if a movie folder is provided in the url it displays the details for that movie. The code for the main script file is: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <? $Mov = stripslashes($_GET['mov']); // Get string from mov variable (if any) if ($Mov != "") { // If string provided in url set page title as movie title and set directory $title = str_replace(".", " ", $Mov); $MovieDir = "/c/Movies/" . $Mov . "/"; } else { // If no string provided then set title for all Movie Listing $title = "Movie List"; } ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><? echo $title; ?></title> <link rel="Shortcut Icon" href="favicon.ico"> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="jquery.js"></script> <script src="jquery.ae.image.resize.min.js"></script> <script src="jquery.smart.columns.js"></script> <script> $(function() { $(".resizeDetails").aeImageResize({height: 550, width: 550}); }); </script> </head> <? /* ----------------------------------------------------------------------------------------------------- | Movie Details Page ( For Specific Movie ) | ----------------------------------------------------------------------------------------------------- */ if ($Mov != "") { $DetailsFile = $MovieDir . "Details.txt"; // Sets Location for details.txt for particular movie $CoverFile = "image.php?mov=" . str_replace("/c/Movies/", "",$MovieDir); // Sets Location for cover for particular movie $CoverFile = $CoverFile . "&type=cover"; // Specifies that the image to be displayed is a cover (full sized movie poster) other option is thumb(nail) $fh = fopen($DetailsFile, 'r'); // Open details file and explose into variables $theData = fread($fh, filesize($DetailsFile)); fclose($fh); $delimiter ="@"; list($title, $year, $genre, $plot, $tag, $imdb, $created) = explode($delimiter, $theData); // Display details and cover in table echo "<table class = \"MovieDetails\" width=\"98%\" height=\"98%\" align=\"center\"><tr><td>"; echo "<b>Title:- </b>$title<br>"; echo "<b>Year:- </b>$year<br>"; echo "<b>Genre:- </b>$genre<br>"; echo "<b>Plot:- </b>$plot<br>"; echo "<b>Tagline:- </b>$tag<br>"; echo "<b>IMDb:- </b><a href='http://www.imdb.com/title/tt" . $imdb . "'>" . $imdb . "</a><br>"; echo "<b>Created:- </b>$created<br>"; echo "</td><td>"; echo "<img src=\"" . $CoverFile . "\" class=\"resizeDetails\" align=\"right\"></tr></td></table>"; } /* ----------------------------------------------------------------------------------------------------- | Directory Listing | ----------------------------------------------------------------------------------------------------- */ else { $folders = array(); if ($handle = opendir('/c/Movies')) { // Location of Movies root folder while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." & $file != "__New" & $file != "cover.jpg") { $folders[] = $file; } } closedir($handle); } asort($folders); $total = sizeof($folders); echo "Listing of Movies<br>\n<b>$total</b> movies in folder.<br><br>\n"; echo "<ul class=\"column\">\n"; foreach($folders as $i) { if($i != "." && $i != "..") { /* Movies are in folders in the format of "Name.Of.Movie[Year]" such as "/c/Movies/Law.Abiding.Citizen[2009]" the next few lines seperate title from year. */ $title = str_replace(".", " ", $i); $title = substr($title,0, strlen($title) -6); $year = substr($i, -6); $year = substr($year,1,-1); $ThumbFile = "image.php?mov=" . str_replace("/c/Movies/", "",$i); $ThumbFile = $ThumbFile . "&type=thumb"; // Generates code used for Smart Columns jQuery Plugin echo "\t<!--List Item For $i-->\n"; echo "\t<li>\n"; echo "\t\t<div class=\"block\">\n"; echo "\t\t\t<a href=\"?mov=" . $i . "\"><img src=\"" . $ThumbFile . "\"><br>" . $title . "<br>" . $year . "</a>\n"; echo "\t\t</div>\n"; echo "\t</li>\n"; echo "\t<!--End List Item For $i-->\n\n"; } } echo "</ul>"; } ?> <body> </body> </html> if you look at the screen shots you can see that the hyper links are displayed correctly but the script cannot send "&" signs through the URL for obvious syntax reasons, but for movies like Angels & Demons this is necessary. Also just be clarify for a movie like "Angels.&.Demons[2009]" this is the folder name within the "/c/Movies/" directory so the name doesnt need to manipulated in that respect. Any help with this would be great, Thanks, Paul. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/206700-using-_get-to-pass-and-through-url/ Share on other sites More sharing options...
Cagecrawler Posted July 4, 2010 Share Posted July 4, 2010 Use urlencode when adding the movie name to the url. Link to comment https://forums.phpfreaks.com/topic/206700-using-_get-to-pass-and-through-url/#findComment-1081015 Share on other sites More sharing options...
Paulio Posted July 4, 2010 Author Share Posted July 4, 2010 Got it cheers mate so simple! Link to comment https://forums.phpfreaks.com/topic/206700-using-_get-to-pass-and-through-url/#findComment-1081021 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.