Jump to content

Linking Users To Correct Videos


Go to solution Solved by Barand,

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
https://forums.phpfreaks.com/topic/306528-linking-users-to-correct-videos/
Share on other sites

  • Solution

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

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 by phreak3r
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.