shizknight Posted October 11, 2008 Share Posted October 11, 2008 Ok i'm completely new to PHP and MySQL, and I'm making a site with a friend just as a fun project to learn something new. In my mysql database, there is a db called "cat", for categories, and tables named "movies", "shows", "cartoons" and so on - at this point you may have deducted it was a streaming media site. Anyway on to the question - I don't understand how in php I can get it to display what I wish based on the url. In the link, site.com/index.php?cat=movies - how can I get it to display the list of movies in the movies table? Thanks in advance, and sorry if this is in the wrong forum. Link to comment https://forums.phpfreaks.com/topic/127950-how-do-urls-in-php-work-in-relation-to-the-database/ Share on other sites More sharing options...
Sangha-08 Posted October 11, 2008 Share Posted October 11, 2008 Ok i'm completely new to PHP and MySQL, and I'm making a site with a friend just as a fun project to learn something new. In my mysql database, there is a db called "cat", for categories, and tables named "movies", "shows", "cartoons" and so on - at this point you may have deducted it was a streaming media site. Anyway on to the question - I don't understand how in php I can get it to display what I wish based on the url. In the link, site.com/index.php?cat=movies - how can I get it to display the list of movies in the movies table? Thanks in advance, and sorry if this is in the wrong forum. lol, I'm also working on a project like that one... but i hardly get any time to do stuff with it... http://www.media2c.com/ (my bro's for random stuff on it atm) erm, btw, to show everything in the table, you've got to loop it... Link to comment https://forums.phpfreaks.com/topic/127950-how-do-urls-in-php-work-in-relation-to-the-database/#findComment-662557 Share on other sites More sharing options...
Stooney Posted October 11, 2008 Share Posted October 11, 2008 Here's an example in it's most basic form. Of course you will need to change 'movie_name' to whatever you named your column. <?php if(isset($_GET['cat'])){ $cat=mysql_real_escape_string($_GET['cat']); $movies=mysql_query("SELECT * FROM $cat"); while($row=mysql_fetch_array($movies)){ echo $row['movie_name'].'<br />'; } } else{ echo 'no category selected'; } ?> Link to comment https://forums.phpfreaks.com/topic/127950-how-do-urls-in-php-work-in-relation-to-the-database/#findComment-662562 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.