Jump to content

Linking Users To Correct Videos


phreak3r

Recommended Posts

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.

 

post-206807-0-07787200-1518554521_thumb.png

post-206807-0-06874800-1518554724_thumb.png

 

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'];
	}
}
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.