ecabrera Posted March 31, 2012 Share Posted March 31, 2012 how does this work i would get all the videos and list them in categorys for example theres is Comedy cat=1 Horror cat=2 Romance cat=3 Drama cat=4 Kids cat=5 Action cat=6 Travel cat=7 http://website.com/list.php?cat=6 then i would chose a category and inside the cat there are videos with ids http://website.com/watch.php?cat=11&video=13 how would i set this up in a database Quote Link to comment https://forums.phpfreaks.com/topic/260105-db-set-up/ Share on other sites More sharing options...
NomadicJosh Posted March 31, 2012 Share Posted March 31, 2012 This should help get you started CREATE TABLE IF NOT EXISTS `video_categories` ( `id` int(11) NOT NULL AUTO_INCREMENT, `category` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; CREATE TABLE IF NOT EXISTS `videos` ( `id` int(11) NOT NULL AUTO_INCREMENT, `cat_id` int(11) NOT NULL, `video_title` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; Now in order to link the "cat_id" in the "videos" table to the primary "id" in the "video_categories" table, you will need to use a JOIN. Or a less elegant way to do it is: SELECT * FROM videos, video_categories WHERE videos.cat_id = video_categories.id; Quote Link to comment https://forums.phpfreaks.com/topic/260105-db-set-up/#findComment-1333124 Share on other sites More sharing options...
ecabrera Posted March 31, 2012 Author Share Posted March 31, 2012 thanks alot Quote Link to comment https://forums.phpfreaks.com/topic/260105-db-set-up/#findComment-1333126 Share on other sites More sharing options...
ecabrera Posted March 31, 2012 Author Share Posted March 31, 2012 ok how would i get like this http://thenewboston.org/tutorials.php Quote Link to comment https://forums.phpfreaks.com/topic/260105-db-set-up/#findComment-1333128 Share on other sites More sharing options...
NomadicJosh Posted April 1, 2012 Share Posted April 1, 2012 If you mean a list of categories, then it would be something similar to this: $sql = "SELECT * FROM videos, video_categories WHERE videos.cat_id = video_categories.id"; $results = mysql_query($sql); while($row = mysql_fetch_array($results)) { echo '<a href="list.php?cat=' . $row['cat_id'] . '">' . $row['category'] . '</a>'; } Quote Link to comment https://forums.phpfreaks.com/topic/260105-db-set-up/#findComment-1333134 Share on other sites More sharing options...
Muddy_Funster Posted April 1, 2012 Share Posted April 1, 2012 @ ecabrera - Your design process is completly back to front! Even in the worlds worst RAD implementation, you always establish the backend data first, then worry about the front end design. Quote Link to comment https://forums.phpfreaks.com/topic/260105-db-set-up/#findComment-1333156 Share on other sites More sharing options...
ecabrera Posted April 1, 2012 Author Share Posted April 1, 2012 OK THANKS AGAIN Quote Link to comment https://forums.phpfreaks.com/topic/260105-db-set-up/#findComment-1333159 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.