iamLearning Posted May 5, 2013 Share Posted May 5, 2013 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']; } ?> Link to comment https://forums.phpfreaks.com/topic/277674-best-way-to-have-unique-links-depending-on-variable/ Share on other sites More sharing options...
MarPlo Posted May 6, 2013 Share Posted May 6, 2013 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 https://forums.phpfreaks.com/topic/277674-best-way-to-have-unique-links-depending-on-variable/#findComment-1428607 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.