Jump to content

Best way to have unique links depending on variable?


iamLearning

Recommended Posts

I want to have a unique link for each posted video.  Like for instance when a user uploads a video MYSQL asigns that video a unique ID. I know how to to this, but then

 

 

How could I then take that ID and create a custom page that other users could link to to view that link?

 

possible with the structure like this

 

?page=video?id=1 

 

 


Right now this is the only bit of code I have dealing with links. 

<?php
if (empty($_GET['page'])){
	header('Location: ?page=home');
	die();
	}

$core_path = dirname(__FILE__);

$pages = scanDir("{$core_path}/pages");
unset($pages[0],$pages[1]);

foreach ($pages as &$page){
$page = substr($page, 0, strpos($page, '.'));
}

if (in_array($_GET['page'], $pages)){
	$include_file = "{$core_path}/pages/{$_GET['page']}.php";
}else{
$include_file = "{$core_path}/pages/home.php";
}

if (array_key_exists('page', $_GET)) {
$currentpage = $_GET['page'];
}
?>
Edited by iamLearning
Link to comment
Share on other sites

Hi,

To get the ID from URL ("file.php?page=video?id=1") use $_GET in file.php. Then make Select in mysql with that id.

if(isset($_GET['id'])) {
  $id = (int) $_GET['id'];
  $sql = "SELECT * FROM table WHERE id=$id LIMIT 1";
  // rest of code ...
}
Link to comment
Share on other sites

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.