hi i want to add multiply categories to my website.Now i can only add movie to one category. the database build that way: -i have categories table that contains only the names of the categories. -in the video table i have a column that contains the name of the category and the script fetches the videos by the category. how can i add more categories to the movie so i could add video to several categories... anyone have idea?is there any way to fetch only videos with specific category?
hm.. you can just seperate with commas "," and then when you call the video from database, split the commas.
i thought so too but how i can retrive it after that ,from mysql i mean... the video table build like that : id|name|description|code|link1|link2|link3|thumb|category|statusv|views|votes|rpoints|featured|queued|dateadded you mean i add the categories like this:category1,category2,category3,.....?
yes, or you can also use serialize() and unserialize(). put the categories IDs (or names) in an array ( $cats = array(name1, name2) ) and the use serialize($cats) so store it in the DB, and unserialize($cats) when you read it. you can also create more database fields to the video table.
i tried to split them like that: $queryrr=mysql_query("Select category from videos"); while($rowpad=mysql_fetch_array($queryrr)){ foreach ($rowpad as $wtf){ $puke = explode(',',$wtf); echo $puke[$j]; } how can i count the the number of the lines fetched from the database?
you forgot to close the while/foreach loop. does it work though? EDIT: this is wrong. let me fix it. $queryrr=mysql_query("Select category from videos"); while($rowpad=mysql_fetch_array($queryrr)){ foreach ($rowpad as $wtf){ $categories = explode(',',$wtf); // Now the categories are inside $categories. use foreach to read them. } } // you can read them like this: foreach($categories as $catid) { // $catid = the category id/name } PHP:
i want after the retrive of the category fetch all the videos in this category...look at this please: $queryrr=mysql_query("Select category from videos"); while($rowpad=mysql_fetch_array($queryrr)){ foreach ($rowpad as $wtf){ $categories = explode(',',$wtf); // Now the categories are inside $categories. use foreach to read them. } } // you can read them like this: foreach($categories as $catid) { if($catid == $preca){ $queryr=mysql_query("Select * from videos where status='active' and queued='' and category='$catid' and featured='$featured' $outin ORDER BY id desc limit $start,$tvideos "); }else{ echo"|"; PHP: its not really working i get only one line from the database...i dont really get why?can you please explain it to me? how can i fetch the videos using the categories?