daniellambert Posted August 13, 2012 Share Posted August 13, 2012 Hi, I've got some frustration regarding a query im trying to do. I've got a video table that i want to try and get some results out ID Name Video usr_ID pairent_vid_ID Deleted created Duration 1 Test1 vid1.avi 22 0 N today 1:32:32 2 Test2 vid2.avi 22 1 N today 1:32:32 3 Test3 vid3.avi 22 1 N today 1:32:32 4 Test4 vid4.avi 22 0 N today 1:32:32 so, if im playing video ID2. How do i then find out the next video in line? when i've only selected video 2's detail. it seems like i need to run a few querys? Get parent ID of video 2 > get video 2 position > load next file and play.. any help would be lovely Quote Link to comment Share on other sites More sharing options...
Mahngiel Posted August 13, 2012 Share Posted August 13, 2012 You can't actually predict the next id in a row. If you wrote added 1 to the current ID, what do you imagine would happen when you reached the last video? You'll need to prepare your output to determine what (if any) the previous and next items would be. That all depends on how you're arriving at your current item - so you're going to have to show some code and explain the situation. Quote Link to comment Share on other sites More sharing options...
daniellambert Posted August 13, 2012 Author Share Posted August 13, 2012 Humm, can you find out where you are in the array? so if i do something like.. // this is the code to find the next video $query = 'SELECT pairent_vid_ID from Video WHERE Video = vid2.avi'; $result = mysql_query($query) or die(mysql_error()); $row_data = mysql_fetch_assoc($result); $query = 'SELECT * FROM Video WHERE pairent_vid_ID = "'.$row_data['pairent_vid_ID'].'"; $result = mysql_query($query) or die(mysql_error()); while($row_data = mysql_fetch_assoc($result)) { if($row_data['Video'] == "vid2.avi") { $row_data = mysql_fetch_assoc($result); return $row_data['Video']; } } Quote Link to comment Share on other sites More sharing options...
Mahngiel Posted August 13, 2012 Share Posted August 13, 2012 You're going to have to explain what you're doing and how you're wanting to accomplish it. There needs to be a logical flow behind your methodology - if there is, I don't understand it. [*] What are you doing and how do you want to get there? [*] What role does the 'parent_id' play? [*] How are you determining the parent? Programming is problem solving. Please define the problem (what is the application doing, supposed to do) and how your application is supposed to work when finished. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 20, 2012 Share Posted August 20, 2012 How are you ordering these records? 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.