Jump to content

pappakaka

Members
  • Posts

    71
  • Joined

  • Last visited

    Never

Everything posted by pappakaka

  1. Hi, I'm very new to JS and trying to learn. Currently I'm trying to make a form validation for my website. What happends in the code below is that when you select an option from a drop down select field, it creates a new list item inside a ul list. I got everything to work except one thing. How many list items you can create. I simply want to restrict the user from selecting more than 3 options from the drop down menu. If you select a 4th option an alert message should pop up but I can't get it to work.. Here's the JS code: function selectGenres(select){ var option = select.options[select.selectedIndex]; var ul = select.parentNode.getElementsByTagName('ul')[0]; var choices = ul.getElementsByTagName('input'); for (var i = 0; i < choices.length; i++) if (choices[i].value == option.value) { alert("The genre is already selected!"); return false; } else if (option == 3) { alert("You can only select 3 genres!"); return false; } var li = document.createElement('li'); var input = document.createElement('input'); var text = document.createTextNode(option.firstChild.data); input.type = 'hidden'; input.name = 'ingredients[]'; input.value = option.value; li.appendChild(input); li.appendChild(text); li.setAttribute('onclick', 'this.parentNode.removeChild(this);'); ul.appendChild(li); } And here is the form to validate: <form name="form1" id="main_form" action="index.php" method="post"> <input id="btn" name="btn" value="Submit" type="submit" /> <div id="form_con"> <table cellspacing="0" cellpadding="0"> <tr> <td valign="middle"> <ul> </ul> <select id="genre_settings" onchange="selectGenres(this);"> <option disabled="disabled">Genre...</option> <option value="01">Animation</option> <option value="02">Action</option> <option value="03">Adventure</option> <option value="04">Animals</option> <option value="05">Comedy</option> ... </select> </td> </tr> </table> </div> </form>
  2. Looked into it and it seems much better yes, thanks!
  3. Ok thanks, so I can basically allow the users to use whatever characters they want in thier password? Or could that possibly be harmful any other way?
  4. I'm trying to secure my login system as much as possible from SQL injections and other attacks. I know that by using mysql_real_escape_string() you can prevent that and I'm using that on for example the username input, but I would like to know if you hash the password before you send it to the database with MD5, do you still need to use mysql_real_escape_string()? A very quick and simple example: <?php $un = $_POST['username']; $pass = $_POST['password']; $pass = md5($pass); mysql_query("SELECT * FROM users WHERE password='$pass' AND username='$un'"); ?> If someone wrote a possible SQL query in the password input, wouldn't that be rendered useless as the md5 will hash it before sending it and therefor "hide" it? Or is there any other reason you wouldn't want people to use sertain characters/symbols in their passwords?
  5. Anyone?
  6. I have a problem, you can see it on this page and then by following the steps below: http://www.randommovietitle.com/Testing/ 1. Try clicking the random button. You will come to a random movie. 2. Go back and and try to choose some options like 2D Animation as genre, between the years 2000-2011. You will get a random movie that fits you options. Also, the query for the options you choose is echo'd out on in the corner aswell as the year span above the logo. 3. After you've done this. Close the tab/page and go to this URL: http://www.randommovietitle.com/Testing/movies.php?mid=100. You will come to the movie Crank. But do you see up in the corner and above the logo? The query and year span is still there and when you click the "Randomize again" button on that page, you will come to a new movie BUT only a movie that fits the options you choose in step 2. I know that this is happening because of the use of $_SESSION. But what I can't figure out is how to make it stop when you leave the movies.php page. Or even better, by using something else than $_SESSION entirely? For example, if I was on this site a few minutes ago and choose a few options that was saved in the $_SESSION veriable. Then come back and want to search for a completely random movie without any options. The options I choose a few minutes ago will still be in the $_SESSION variable and used in the search. How can I change this? Here is the form on the first page and the code I use on movies.php: <form class="main_form" action="movies.php" method="post" name="form1"> <input class="random_btn" name="next_btn" value="Random" type="submit" onclick="return validate()" /><br /> <div class="index_bgbox"> <label class="genre_label" value="genre">Genre</label><br /> <select multiple="multiple" name="genre[]" id="genre" size="7"> <option value="01">2D Animation</option> <option value="02">3D Animation</option> <option value="03">Action</option> <option value="04">Adventure</option> <option value="05">Animals</option> <option value="06">Comedy</option> <option value="07">Comics Adaptation</option> <option value="08">Crime</option> <option value="09">Dance</option> <option value="10">Disaster</option> <option value="11">Documentary</option> <option value="12">Drama</option> <option value="13">Family</option> <option value="14">Fantasy</option> <option value="15">Fighting</option> <option value="16">Game Adaptation</option> <option value="17">History</option> <option value="18">Horror</option> <option value="19">Thriller</option> <option value="20">Romance</option> <option value="21">Music</option> <option value="22">Mystery</option> <option value="23">Parody</option> <option value="24">Psychological</option> <option value="25">Sci-Fi</option> <option value="26">Sport</option> <option value="27">Teen</option> <option value="28">War</option> <option value="29">Western</option> </select> <label class="year_label" value="YearForm">Year</label><br /> <select class="year_from" name="YearFrom"> <option value="">Select From</option> <option value="1930">1930</option> <option value="1931">1931</option> <option value="1932">1932</option> <option value="1933">1933</option> ...etc... </select> <select class="year_to" name="YearTo"> <option value="">Select To</option> <option value="1930">1930</option> <option value="1931">1931</option> <option value="1932">1932</option> <option value="1933">1933</option> ...etc... </select> </div> </form> <?php session_start(); require("Includes/connection.php"); $connection = @mysql_connect($ControlHost, $ControlUser, $ControlPass) or die("Couldn't connect to server"); $db = @mysql_select_db("$ControlDb", $connection) or die("Couldn't select database"); if (isset($_GET['mid'])) { echo $_SESSION['genre_string']; $mid=(int)$_GET['mid']; $result = mysql_query("SELECT * FROM movie WHERE MID='$mid'"); $row = mysql_fetch_array($result); $MID = $row["MID"]; $Title = $row["Title"]; $YearFrom = $row["YearFrom"]; $RMTRating = $row["RMTRating"]; $IMDBRating = $row["IMDBRating"]; $Description = $row["Description"]; $Genree = $row["Genree"]; $Genree = explode(",", $Genree); $Poster = $row["Poster"]; $TrailerLink = $row["TrailerLink"]; $MoreInfo = $row["MoreInfo"]; $Prequel = $row["Prequel"]; $Sequel = $row["Sequel"]; } elseif (!isset($_GET['mid'])) { $genre_string=""; //$genre_string1=""; if(empty($_REQUEST['genreString1'])){ if(!empty($_REQUEST['genre'])){ $genre=$_REQUEST['genre']; $total_genre=count($genre); $genre_string1=""; for($i=0; $i<$total_genre;$i++){ $genre_string .= "Genree LIKE '%" . $genre[$i] . '%' . "'". " AND "; $genre_string1 .= $genre[$i] . " OR "; } $genre_string = substr($genre_string, 0, -4); $genre_string1 = substr($genre_string1, 0, -4); $genre_string = "WHERE" . "(" . $genre_string . ")"; } if( !empty($_REQUEST['YearFrom']) ){ $YearFrom = $_REQUEST['YearFrom']; $YearTo = $_REQUEST['YearTo']; if(!empty($_REQUEST['genre'])) $genre_string .= " AND "; else $genre_string .= "Where "; $genre_string .= "(YearFrom BETWEEN $YearFrom AND $YearTo)"; } }elseif(!empty($_REQUEST['genreString1'])){ $genre_string1 = $_REQUEST['genreString1']; $pieces = explode(" OR ", $genre_string1); for($ii=0; $ii<count($pieces);$ii++){ $genre_string .= "Genree LIKE '%" . trim($pieces[$ii]) . '%' . "'" . " AND "; $genre[]=trim($pieces[$ii]); } $genre_string = substr($genre_string, 0, -4); if( !is_numeric(trim($pieces[0]))) $genre_string = ""; else $genre_string = "WHERE" . "(" . $genre_string . ")"; if( !empty($_REQUEST['YearFrom']) ){echo "111"; $YearFrom = $_REQUEST['YearFrom']; $YearTo = $_REQUEST['YearTo']; if( is_numeric(trim($pieces[0]))) $genre_string .= " AND (YearFrom BETWEEN $YearFrom AND $YearTo)"; if( !is_numeric(trim($pieces[0]))) $genre_string = " Where (YearFrom BETWEEN $YearFrom AND $YearTo)"; } } if (!empty($genre_string)) { $_SESSION['genre_string'] = $genre_string; $YearFrom = $_REQUEST['YearFrom']; $YearTo = $_REQUEST['YearTo']; $_SESSION['YearFrom'] = $YearFrom; $_SESSION['YearTo'] = $YearTo; } else { $genre_string = $_SESSION['genre_string']; } $result = mysql_query("SELECT * FROM movie $genre_string ORDER BY RAND() LIMIT 0,1"); $row = mysql_fetch_array($result); $MID = $row["MID"]; header( "Location: movies.php?mid=" . $MID ) ; } ?>
  7. Yes by using $id=(int)$_GET['id']; it worked much better thank you!
  8. Thank you so much, this actually worked! So simple! Thank you!
  9. I have a website that uses PHP to display content. That content is ofcourse taken from a database in MySQL, and only 1 row at a time is displayed on the page. The row of content that is displayed is randomly selected every time the page loads. So the page change (almost) everytime you reload it. Here is the problem. Even if the content on the page change, the URL does not. So there is no way to display a specific row. For example: I load the page www.website.com/row.php and a random row with ID 1 is displayed. Then I reload the page and a new row with the ID 2 is displayed, but the URL is still the same. What I need is so that, when it selects a random row, the ID of that row is added to the URL as a query. Like this: Row 1 = www.website.com/row.php?id=1 Row 2 = www.website.com/row.php?id=2 That way, if you only go to www.website.com/row.php. The page reloads and a random row is displayed with the ID of that row added to the URL. And if you go to www.website.com/row.php?id=1 directly, no random row is selected, only the row that matches the ID of the URL. I hope you understand and can help me, I really don't know how to explain it better. Here is the code I use right now to select a random row from the database and also to calculate a few inputs the user can make on the previous page on the site. <?php require("Includes/connection.php"); $connection = @mysql_connect($ControlHost, $ControlUser, $ControlPass) or die("Couldn't connect to server"); $db = @mysql_select_db("$ControlDb", $connection) or die("Couldn't select database"); $genre_string=""; //$genre_string1=""; if(empty($_REQUEST['genreString1'])){ if(!empty($_REQUEST['genre'])){ $genre=$_REQUEST['genre']; $total_genre=count($genre); $genre_string1=""; for($i=0; $i<$total_genre;$i++){ $genre_string .= "Genree LIKE '%" . $genre[$i] . '%' . "'". " AND "; $genre_string1 .= $genre[$i] . " OR "; } $genre_string = substr($genre_string, 0, -4); $genre_string1 = substr($genre_string1, 0, -4); $genre_string = "WHERE" . "(" . $genre_string . ")"; } if( !empty($_REQUEST['YearFrom']) ){ $YearFrom = $_REQUEST['YearFrom']; $YearTo = $_REQUEST['YearTo']; if(!empty($_REQUEST['genre'])) $genre_string .= " AND "; else $genre_string .= "Where "; $genre_string .= "(YearFrom BETWEEN $YearFrom AND $YearTo)"; } }elseif(!empty($_REQUEST['genreString1'])){ $genre_string1 = $_REQUEST['genreString1']; $pieces = explode(" OR ", $genre_string1); for($ii=0; $ii<count($pieces);$ii++){ $genre_string .= "Genree LIKE '%" . trim($pieces[$ii]) . '%' . "'" . " AND "; $genre[]=trim($pieces[$ii]); } $genre_string = substr($genre_string, 0, -4); if( !is_numeric(trim($pieces[0]))) $genre_string = ""; else $genre_string = "WHERE" . "(" . $genre_string . ")"; if( !empty($_REQUEST['YearFrom']) ){echo "111"; $YearFrom = $_REQUEST['YearFrom']; $YearTo = $_REQUEST['YearTo']; if( is_numeric(trim($pieces[0]))) $genre_string .= " AND (YearFrom BETWEEN $YearFrom AND $YearTo)"; if( !is_numeric(trim($pieces[0]))) $genre_string = " Where (YearFrom BETWEEN $YearFrom AND $YearTo)"; } } //echo $genre_string; //echo "SELECT * FROM movie $genre_string ORDER BY RAND() LIMIT 0,1<br />"; $result = mysql_query("SELECT * FROM movie $genre_string ORDER BY RAND() LIMIT 0,1"); //echo $er=mysql_num_rows($result);exit; $row = mysql_fetch_array($result); $MID = $row["MID"]; $Title = $row["Title"]; $YearFrom = $row["YearFrom"]; $RMTRating = $row["RMTRating"]; $IMDBRating = $row["IMDBRating"]; $Description = $row["Description"]; $Genree = $row["Genree"]; $Genree = explode(",", $Genree); $Poster = $row["Poster"]; $TrailerLink = $row["TrailerLink"]; $MoreInfo = $row["MoreInfo"]; $Prequel = $row["Prequel"]; $Sequel = $row["Sequel"]; ?> Then you I imagine it would be something like this to make each URL/row unique: $currentdomain = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; if ($currentdomain == "http://www.website.com/row.php") { header( "Location: row.php?id=" . $MID ) ; }
  10. The MID is just a short I used in the MySQL database instead of MovieID. So I tought that would be a way to keep track of each movie, or by using the title of the movie in the end like this: http://www.randommovietitle.com/movies.php?title=titanic or http://www.randommovietitle.com/movies.php?mid=123456
  11. What I mean is like on the forum. When you post a new thread it get it's own URL like this: http://www.phpfreaks.com/forums/index.php?topic=335006.0 See, it adds a few lines to the URL so you can go to this page directly! I checked the code but it can't be a $_POST or $_GET problem as I'm not doing anything to make the URL specific for the page.
  12. Hi, I have a problem with pagination. This is my site: http://www.randommovietitle.com/ When you click random you get to a new page (called movies.php) wich displays random content taken from a mysql database. When you click Randomize Again, the same thing happends and so on. What I need is so that every page has it's own URL like this somehow: What it looks like now: Content about the movie Titanic is loaded: http://www.randommovietitle.com/movies.php Content about the movie Avatar is loaded: http://www.randommovietitle.com/movies.php What I need it to look like: Content about the movie Titanic is loaded: http://www.randommovietitle.com/movies.php?mid=xxxxxx Content about the movie Avatar is loaded: http://www.randommovietitle.com/movies.php?mid=xxxxxx I know you can do this but just don't know how? Please help?
  13. Ok, what does the forum rules say about that? Can ju post a thread about paying someone for work?
  14. This is what I get if I put the print_r($_POST); inside the genre_string statement: Array ([next_btn] => Random [YearFrom] => ) I do not know if I did this correctly cause I try to understand but honestly I have no idea what I'm doing!
  15. It says: SELECT * FROM movie ORDER BY RAND() LIMIT 0,1
  16. It didn't do anything, still get all the movies in the database no matter what genre I select
  17. Hi, i'm gonna try to explain my problem with as few words as possible. I have recently started this website: http://www.randommovietitle.com As you can see on the first page you can select a range of years and a number of genres from the Genre selection box. You can select 1, 2 or 3 genres and then click random. When you click random, a random movie should appear ONLY if it has ALL the genres you selected. Let me give you an example: You select Action and Comedy and click random. Only movies that has BOTH Action and Comedy will show up. (same thing if you select 3 genres ofcourse) The problem is that with the code I have now it isn't working! When I select, for example Drama and Sci-Fi. Every movie in the database that has Drama will show up, and every movie that has Sci-Fi will show up. What I need is so that only movies that has BOTH Drama and Sci-Fi appears. I'm not good AT ALL with php, I only know the very basic stuff. I got the code from a guy who was willing to help me at first but then coudn't do it anymore. I've been trying to change the code by myself for the past 3 days but got nowhere, only got more confused! The code below is ALL the code that has to do with the genre selection! This is the first page code: <form class="main_form" action="movies.php" method="post" name="form1"> <input class="random_btn" name="next_btn" value="Random" type="submit" onclick="return validate()" /><br /> <div class="index_bgbox"> <label class="genre_label" value="genre">Genre</label><br /> <select multiple="multiple" name="genre[]" id="genre" size="7"> <option value="1">2D Animation</option> <option value="2">3D Animation</option> <option value="3">Action</option> <option value="4">Adventure</option> <option value="5">Animals</option> <option value="6">Comedy</option> <option value="7">Comics Adaptation</option> <option value="8">Crime</option> <option value="9">Dance</option> <option value="10">Disaster</option> <option value="11">Documentary</option> <option value="12">Drama</option> <option value="13">Family</option> <option value="14">Fantasy</option> <option value="15">Fighting</option> <option value="16">Game Adaptation</option> <option value="17">History</option> <option value="18">Horror</option> <option value="19">Thriller</option> <option value="20">Romance</option> <option value="21">Music</option> <option value="22">Mystery</option> <option value="23">Parody</option> <option value="24">Psychological</option> <option value="25">Sci-Fi</option> <option value="26">Sport</option> <option value="27">Teen</option> <option value="28">War</option> <option value="29">Western</option> </select> <label class="year_label" value="YearForm">Year</label><br /> <select class="year_from" name="YearFrom"> <option value="">Select From</option> <option value="1970">1970</option> <option value="1971">1971</option> <option value="1972">1972</option> <option value="1973">1973</option> <option value="1974">1974</option> <option value="1975">1975</option> <option value="1976">1976</option> <option value="1977">1977</option> <option value="1978">1978</option> <option value="1979">1979</option> <option value="1980">1980</option> <option value="1981">1981</option> <option value="1982">1982</option> <option value="1983">1983</option> <option value="1984">1984</option> <option value="1985">1985</option> <option value="1986">1986</option> <option value="1987">1987</option> <option value="1988">1988</option> <option value="1989">1989</option> <option value="1990">1990</option> <option value="1991">1991</option> <option value="1992">1992</option> <option value="1993">1993</option> <option value="1994">1994</option> <option value="1995">1995</option> <option value="1996">1996</option> <option value="1997">1997</option> <option value="1998">1998</option> <option value="1999">1999</option> <option value="2000">2000</option> <option value="2001">2001</option> <option value="2002">2002</option> <option value="2003">2003</option> <option value="2004">2004</option> <option value="2005">2005</option> <option value="2006">2006</option> <option value="2007">2007</option> <option value="2008">2008</option> <option value="2009">2009</option> <option value="2010">2010</option> <option value="2011">2011</option> </select> <select class="year_to" name="YearTo"> <option value="">Select To</option> <option value="1970">1970</option> <option value="1971">1971</option> <option value="1972">1972</option> <option value="1973">1973</option> <option value="1974">1974</option> <option value="1975">1975</option> <option value="1976">1976</option> <option value="1977">1977</option> <option value="1978">1978</option> <option value="1979">1979</option> <option value="1980">1980</option> <option value="1981">1981</option> <option value="1982">1982</option> <option value="1983">1983</option> <option value="1984">1984</option> <option value="1985">1985</option> <option value="1986">1986</option> <option value="1987">1987</option> <option value="1988">1988</option> <option value="1989">1989</option> <option value="1990">1990</option> <option value="1991">1991</option> <option value="1992">1992</option> <option value="1993">1993</option> <option value="1994">1994</option> <option value="1995">1995</option> <option value="1996">1996</option> <option value="1997">1997</option> <option value="1998">1998</option> <option value="1999">1999</option> <option value="2000">2000</option> <option value="2001">2001</option> <option value="2002">2002</option> <option value="2003">2003</option> <option value="2004">2004</option> <option value="2005">2005</option> <option value="2006">2006</option> <option value="2007">2007</option> <option value="2008">2008</option> <option value="2009">2009</option> <option value="2010">2010</option> <option value="2011">2011</option> </select> </div> <?php include("Includes/footer.php"); ?> </form> Movie pages code: <?php require("Includes/connection.php"); $connection = @mysql_connect($ControlHost, $ControlUser, $ControlPass) or die("Couldn't connect to server"); $db = @mysql_select_db("$ControlDb", $connection) or die("Couldn't select database"); $genre_string=""; //$genre_string1=""; if(empty($_REQUEST['genreString1'])){ if(!empty($_REQUEST['genre'])){ $genre=$_REQUEST['genre']; $total_genre=count($genre); $genre_string1=""; for($i=0; $i<$total_genre;$i++){ $genre_string .= "Genree LIKE '%" . $genre[$i] . '%' . "'". " OR "; $genre_string1 .= $genre[$i] . " OR "; } $genre_string = substr($genre_string, 0, -4); $genre_string1 = substr($genre_string1, 0, -4); $genre_string = "WHERE" . "(" . $genre_string . ")"; } if( !empty($_REQUEST['YearFrom']) ){ $YearFrom = $_REQUEST['YearFrom']; $YearTo = $_REQUEST['YearTo']; if(!empty($_REQUEST['genre'])) $genre_string .= " AND "; else $genre_string .= "Where "; $genre_string .= "(YearFrom BETWEEN $YearFrom AND $YearTo)"; } }elseif(!empty($_REQUEST['genreString1'])){ $genre_string1 = $_REQUEST['genreString1']; $pieces = explode(" OR ", $genre_string1); for($ii=0; $ii<count($pieces);$ii++){ $genre_string .= "Genree LIKE '%" . trim($pieces[$ii]) . '%' . "'" . " OR "; $genre[]=trim($pieces[$ii]); } $genre_string = substr($genre_string, 0, -4); if( !is_numeric(trim($pieces[0]))) $genre_string = ""; else $genre_string = "WHERE" . "(" . $genre_string . ")"; if( !empty($_REQUEST['YearFrom']) ){//echo "111"; $YearFrom = $_REQUEST['YearFrom']; $YearTo = $_REQUEST['YearTo']; if( is_numeric(trim($pieces[0]))) $genre_string .= " AND (YearFrom BETWEEN $YearFrom AND $YearTo)"; if( !is_numeric(trim($pieces[0]))) $genre_string = " Where (YearFrom BETWEEN $YearFrom AND $YearTo)"; } }//echo $genre_string; //echo "SELECT * FROM movie $genre_string ORDER BY RAND() LIMIT 0,1<br />"; $result = mysql_query("SELECT * FROM movie $genre_string ORDER BY RAND() LIMIT 0,1"); //echo $er=mysql_num_rows($result);exit; $row = mysql_fetch_array($result); $MID = $row["MID"]; $Title = $row["Title"]; $YearFrom = $row["YearFrom"]; $RMTRating = $row["RMTRating"]; $IMDBRating = $row["IMDBRating"]; $Description = $row["Description"]; $Genree = $row["Genree"]; $Genree = explode(",", $Genree); $Poster = $row["Poster"]; $TrailerLink = $row["TrailerLink"]; $MoreInfo = $row["MoreInfo"]; ?> <table class="genrebox" border="0"> <tr> <td width="72"><b>Genres:</b> </td> <td width="170"> <?php if( !empty($Genree[1]) ){ if($Genree[1] == "1") echo "2D Animation"; elseif($Genree[1] == "2") echo "3D Animation"; elseif($Genree[1] == "3") echo "Action"; elseif($Genree[1] == "4") echo "Adventure"; elseif($Genree[1] == "5") echo "Animals"; elseif($Genree[1] == "6") echo "Comedy"; elseif($Genree[1] == "7") echo "Comics Adaptation"; elseif($Genree[1] == "8") echo "Crime"; elseif($Genree[1] == "9") echo "Dance"; elseif($Genree[1] == "10") echo "Disaster"; elseif($Genree[1] == "11") echo "Documentary"; elseif($Genree[1] == "12") echo "Drama"; elseif($Genree[1] == "13") echo "Family"; elseif($Genree[1] == "14") echo "Fantasy"; elseif($Genree[1] == "15") echo "Fighting"; elseif($Genree[1] == "16") echo "Game Adaptation"; elseif($Genree[1] == "17") echo "History"; elseif($Genree[1] == "18") echo "Horror"; elseif($Genree[1] == "19") echo "Thriller"; elseif($Genree[1] == "20") echo "Romance"; elseif($Genree[1] == "21") echo "Music"; elseif($Genree[1] == "22") echo "Mystery"; elseif($Genree[1] == "23") echo "Parody"; elseif($Genree[1] == "24") echo "Psychological"; elseif($Genree[1] == "25") echo "Sci-Fi"; elseif($Genree[1] == "26") echo "Sport"; elseif($Genree[1] == "27") echo "Teen"; elseif($Genree[1] == "28") echo "War"; elseif($Genree[1] == "29") echo "Western"; } ?> </td><br /> <td width="170"><?php if( !empty($Genree[2]) ){ if($Genree[2] == "1") echo "2D Animation"; elseif($Genree[2] == "2") echo "3D Animation"; elseif($Genree[2] == "3") echo "Action"; elseif($Genree[2] == "4") echo "Adventure"; elseif($Genree[2] == "5") echo "Animals"; elseif($Genree[2] == "6") echo "Comedy"; elseif($Genree[2] == "7") echo "Comics Adaptation"; elseif($Genree[2] == "8") echo "Crime"; elseif($Genree[2] == "9") echo "Dance"; elseif($Genree[2] == "10") echo "Disaster"; elseif($Genree[2] == "11") echo "Documentary"; elseif($Genree[2] == "12") echo "Drama"; elseif($Genree[2] == "13") echo "Family"; elseif($Genree[2] == "14") echo "Fantasy"; elseif($Genree[2] == "15") echo "Fighting"; elseif($Genree[2] == "16") echo "Game Adaptation"; elseif($Genree[2] == "17") echo "History"; elseif($Genree[2] == "18") echo "Horror"; elseif($Genree[2] == "19") echo "Thriller"; elseif($Genree[2] == "20") echo "Romance"; elseif($Genree[2] == "21") echo "Music"; elseif($Genree[2] == "22") echo "Mystery"; elseif($Genree[2] == "23") echo "Parody"; elseif($Genree[2] == "24") echo "Psychological"; elseif($Genree[2] == "25") echo "Sci-Fi"; elseif($Genree[2] == "26") echo "Sport"; elseif($Genree[2] == "27") echo "Teen"; elseif($Genree[2] == "28") echo "War"; elseif($Genree[2] == "29") echo "Western"; } ?></td> <td width="170"><?php if( !empty($Genree[3]) ){ if($Genree[3] == "1") echo "2D Animation"; elseif($Genree[3] == "2") echo "3D Animation"; elseif($Genree[3] == "3") echo "Action"; elseif($Genree[3] == "4") echo "Adventure"; elseif($Genree[3] == "5") echo "Animals"; elseif($Genree[3] == "6") echo "Comedy"; elseif($Genree[3] == "7") echo "Comics Adaptation"; elseif($Genree[3] == "8") echo "Crime"; elseif($Genree[3] == "9") echo "Dance"; elseif($Genree[3] == "10") echo "Disaster"; elseif($Genree[3] == "11") echo "Documentary"; elseif($Genree[3] == "12") echo "Drama"; elseif($Genree[3] == "13") echo "Family"; elseif($Genree[3] == "14") echo "Fantasy"; elseif($Genree[3] == "15") echo "Fighting"; elseif($Genree[3] == "16") echo "Game Adaptation"; elseif($Genree[3] == "17") echo "History"; elseif($Genree[3] == "18") echo "Horror"; elseif($Genree[3] == "19") echo "Thriller"; elseif($Genree[3] == "20") echo "Romance"; elseif($Genree[3] == "21") echo "Music"; elseif($Genree[3] == "22") echo "Mystery"; elseif($Genree[3] == "23") echo "Parody"; elseif($Genree[3] == "24") echo "Psychological"; elseif($Genree[3] == "25") echo "Sci-Fi"; elseif($Genree[3] == "26") echo "Sport"; elseif($Genree[3] == "27") echo "Teen"; elseif($Genree[3] == "28") echo "War"; elseif($Genree[3] == "29") echo "Western"; } ?></td> </tr> </table> </div> <?php } ?> <a id="various4" href="Includes/trailer.php?MID=<?php echo $MID;?>" class="trailer_btn" name="trailer_btn">Watch Trailer</a> <form action="movies.php" name="form1" method="post"> <input class="next_btn" name="next_btn" value="Randomize Again" type="submit" /> <input name="genreString1" value="<?php echo $genre_string1; ?>" type="hidden" /> <input name="YearTo" value="<?php echo $_REQUEST['YearTo']; ?>" type="hidden" /> <input name="YearFrom" value="<?php echo $_REQUEST['YearFrom']; ?>" type="hidden" /> </form>
  18. I use: <form action="all_links.php" method="post"> And yes the whole website use on pagination!
  19. Ok, now i've tried to get that to work for a while but something is wrong cause it isn't working. I used your code, and yes the values in the form (date, clicks, ratings, comments) has the same names as the colomns/fields in my table so that can't be the problem. I've treid to test it in a "test.php" file with only the form and code in the same file with no succsess. Could the problem be that the page doesn't automaticly refresh and order the content in the page correspondly when a user selects a value from the dropdown?
  20. Ok, so if i use this instead, what should i do? <select name="sortby_dropdown"> <option value="date" selected="selected">Date</option> <option value="clicks">Clicks</option> <option value="ratings">Ratings</option> <option value="comments">Comments</option> </select>
  21. Ok i'm trying to make a dropdown menu to sort content on my site. The dropdown looks like this: <select> <option selected="selected">Date</option> <option>Clicks</option> <option>Ratings</option> <option>Comments</option> </select> The content that the dropdown needs to sort are taken from my MySQL database and put on the site using these lines of code: (there is alot more code to do other stuff aswell, but that isn't importand for my problem) $sql = "SELECT * FROM links LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $dyn_table = '<table class="main_table">'; while ($row = mysql_fetch_assoc($result)) { etc... The dropdown and the php script that inserts the content on the page are (and needs to be) in two seperate files. So how can i make so that when a user selects "Sort by: Clicks" for example, the page refresh and maybe inserts "ORDER BY clicks ASC" into "$sql = "SELECT * FROM links LIMIT $offset, $rowsperpage";"or something?? I'm really open for ideas here, Javascript and jQuery is also welcome if it needs to be used!
  22. Thank you! Pagination was exactly what i needed, followed this guide (http://www.phpfreaks.com/tutorial/basic-pagination) and solved it!
  23. Ok i have a question about a dynamic website.. What i have is a site that takes content from the MySQL database and load it into the index.php file. And i know how to change the content of the page when i move around in the navigation, e.g when i click on the "HOME" tab, the content for the home page is shown and when i click on "ABOUT", the information about my site is shown and so on.. Now for my question! I want the content too move everyday automaticly. For example, today i type in some content in the MySQL database that i want to be shown on my website for today. But tomorrow i want the content to have been moved to page 2, and the next day page 3 and so on.. So that everyday i can type in new content, and all the old pages get pushed back one page if that makes sense? Sorry but I have no actuall code for this cause i don't know how to start, but i guess you could use dates and "if else" statements to determine when the pages should be moved and not. Example code would be greatly appriciated! And when i say moved between pages, i mean like this: Today: www.mywebsite.com/index.php?pageid=1 - example 2 www.mywebsite.com/index.php?pageid=2 - example 1 www.mywebsite.com/index.php?pageid=3 - empty Tomorrow: www.mywebsite.com/index.php?pageid=1 - example 3 www.mywebsite.com/index.php?pageid=2 - example 2 www.mywebsite.com/index.php?pageid=3 - example 1
  24. Oh, ok now i see. Thank you! Will try to do a test website like that..
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.