scriptjet Posted February 7, 2011 Share Posted February 7, 2011 $genre = $_POST['listMovies']; $result = mysql_query("SELECT * FROM movieTable SORT BY title"); $column = 1; define("COLUMNS", 2); $movieCounter = 0; echo "<h1>by " .$genre ."</h1><table>"; while ($info = mysql_fetch_array($result)) { $genre1 = $info['genre1']; $genre2 = $info['genre2']; $genre3 = $info['genre3']; $title = $info['title']; $link = $info['imdbLink']; if ($genre == $genre1 || $genre == $genre2 || $genre == $genre3) { $movieCounter++; if ($column == 1) {echo "<tr>";} echo "<td><a href='" .$link ."'>".$title ."</a></td>"; $column++; if ($column > COLUMNS) { echo "</tr>"; $column = 1; } } } echo "<table><tr><td>" .$movieCounter ." movies found.</td></tr></table>"; if ($column > 1 && $column <= COLUMNS) { while ($column++ <= COLUMNS) echo "<td></td>"; echo "</tr>"; } echo "</table>"; $genre = ""; now that you have the code, i have 2 questions about this. first one is this. whenever i first load this code everything is empty as it should be. then i select from a form a movie genre and everything work lovely. the problem is that the movies that are loaded are still there when i come back to the page. i need a way to clearing this out everytime the code is run, while still displaying the movies. also .. this is just a php noob question here. why is that when i run a query like this $result = mysql_query("SELECT * FROM movieTable SORT BY title"); i cannot use mysql_fetch_array or mysql_fetch_row? but it works when i do it like this $result = mysql_query("SELECT * FROM movieTable"); like i said that's just a noob question that i cannot for the life of me figure out. thanks for the help, this forum has been the biggest help to me learning php. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 7, 2011 Share Posted February 7, 2011 If you're using the back button, it's up to the browser to clear the fields, not php. For your second question, there is no SORT BY, it's ORDER BY, if you were checking for and handling MySQL errors, you'd know that. Quote Link to comment Share on other sites More sharing options...
scriptjet Posted February 7, 2011 Author Share Posted February 7, 2011 yeah thanks for the ORDER BY -- not really sure what i was thinking there. I was getting the error, but it was just saying invalid argument in the search. and i'm not really sure what to ask about the clearing the form. it's not really a form that needs to be cleared. perhaps it might be better if you went to the site to see it in action. http://www.projectscriptjet.com/drupal/node/18 the first time you go there it works right, but as soon as you choose a genre from the menu on the left it's like it keeps the movies in a holder. i want it to be blank every time the page opens, i know it's gotta be some if statement but i'm not sure what it would be. i'm thinking that maybe i should set the if to be an isset of the buttons from the menu? Quote Link to comment Share on other sites More sharing options...
scriptjet Posted February 7, 2011 Author Share Posted February 7, 2011 i solved the problem -- i need to isset $genre; thanks for the help again. it's great for a noob to have such a valuable resource as the people on this site. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.