phreak3r Posted February 13, 2018 Share Posted February 13, 2018 The images serve as a link to the video. The images, when clicked are supposed to go to a page that displays the video respective to its uploader, title, description, etc. However that is not the case. Upon clicking on any thumbnail, you are lead to the latest video uploaded from that particular user in the database. How can I fix this? Code for the rendering of videos onto the page: <div class="wrapper"> <?php $username = $_SESSION['username']; $sql = "SELECT thumbnail, video_title from videos0 WHERE uploader='$username'"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_assoc($result)) { $thumbnail = "/soapbox/" . $row['thumbnail']; $title = $row['video_title']; ?> <a href="<?php echo "/soapbox/video.php"; ?>" class="link"> <div class="img-container"> <img src="<?php echo $thumbnail; ?>" class="thumbnail_img" width="276" height="183"> <?php echo $title; ?> </div> </a> <?php } } else { ?> <div class="no-vid-msg">No content available.</div> <?php } ?> </div> When pressing the Video 1 link/thumbnail, you are still taken to the Video 2 video, the most recent file in the database. How can I keep that from happening? It has to do with the while loop in the video.php file I am sure. Here's the code for the video.php while loop: $username = $_SESSION['username']; $sql = "SELECT video, thumbnail, video_title, video_desc from videos0 WHERE uploader='$username'"; $result = mysqli_query($conn, $sql); //$row = mysqli_fetch_assoc($result); if (mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_assoc($result)) { $video = "/soapbox/" . $row['video']; $title = $row['video_title']; } } ?> Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted February 13, 2018 Solution Share Posted February 13, 2018 Pass the id of the video in the link and then retrieve the one with that id. At the moment, if more than one video in the query results you are left with values from the last row in $video and $title Quote Link to comment Share on other sites More sharing options...
phreak3r Posted February 13, 2018 Author Share Posted February 13, 2018 (edited) Pass the id of the video in the link and then retrieve the one with that id. At the moment, if more than one video in the query results you are left with values from the last row in $video and $title Not sure what you mean by the first one. I see why the usage of IDs are recommended, I will get to it. Thank You! EDIT: I am not using IDs at the moment. Edited February 13, 2018 by phreak3r Quote Link to comment Share on other sites More sharing options...
phreak3r Posted February 13, 2018 Author Share Posted February 13, 2018 Nevermind, I figured out your suggestion. Thank you! 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.