'www.url.com/Video.php?Video_ID=7' Can anyone explain?

How can I emplement the ?Video_ID=7 idea into my website

Page 1 of 1

5 Replies - 8439 Views - Last Post: 15 February 2010 - 09:23 AM Rate Topic: -----

#1 Guest_David Tucker*


Reputation:

'www.url.com/Video.php?Video_ID=7' Can anyone explain?

Posted 14 February 2010 - 02:31 AM

On multiple PHP websites, I see the 'filename.php?ID=[somenumber]'. I always wanted to use that into my website so I won't have to have 300 different pages to show 300 different videos.

It's the same file, but when the 'ID=[somenumber]' changes into'ID=[someothernumber]' the content changes. Can someone tell me the use of these, links to tutorials, or even the name. Any information will be helpful. I know some PHP, but not enough to make extravagant scripts.

I'm sorry if I can't be any clearer than that, since I don't even know what I'm talking about in a sense.

Is This A Good Question/Topic? 0

Replies To: 'www.url.com/Video.php?Video_ID=7' Can anyone explain?

#2 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5313
  • View blog
  • Posts: 27,220
  • Joined: 10-May 07

Re: 'www.url.com/Video.php?Video_ID=7' Can anyone explain?

Posted 14 February 2010 - 02:35 AM

You can access the ID=[somenumber] in the $_GET array.

if(isset($_GET[id])) {
  $ID=$_GET[id];
  echo "ID :<hr>$ID";
}
else {
  echo "ID not set";
}



You can find more information on $_GET, $_POST, & methods from this PHP tutorial
Was This Post Helpful? 0
  • +
  • -

#3 Guest_David Tucker*


Reputation:

Re: 'www.url.com/Video.php?Video_ID=7' Can anyone explain?

Posted 14 February 2010 - 02:59 AM

View PostDavid Tucker, on 14 February 2010 - 01:31 AM, said:

On multiple PHP websites, I see the 'filename.php?ID=[somenumber]'. I always wanted to use that into my website so I won't have to have 300 different pages to show 300 different videos.

It's the same file, but when the 'ID=[somenumber]' changes into'ID=[someothernumber]' the content changes. Can someone tell me the use of these, links to tutorials, or even the name. Any information will be helpful. I know some PHP, but not enough to make extravagant scripts.

I'm sorry if I can't be any clearer than that, since I don't even know what I'm talking about in a sense.


No what I'm saying is that I have two videos to display. Video A and Video B. When I click the link to take me to Video A, the URL will say 'http://www.url.com/video.php?ID=01'. Then if I click the link to go to Video B the URL will say 'http://www.url.com/video.php?ID=02'. I need a way to tell what the ID is, and show the content related to that specific ID number aka ID=01 will display Video A and ID=02 will display Video B.

What no2pencil said might be true, but he really doesn't tell me how to emplement it, but I am of limited knowledge when it comes to programming since I am only in High School. Anyway, is there a specific function of some sort that can read the user's URL bar and tell what ID is equal too and set a variable or something of that sort?

Still doesn't make sense to me, but that's the best I can explain what I'm wanting to know.
Was This Post Helpful? 0

#4 Guest_David Tucker*


Reputation:

Re: 'www.url.com/Video.php?Video_ID=7' Can anyone explain?

Posted 14 February 2010 - 03:42 AM

I'm an idiot... or a noob, most likely both. Anyways no2pencil was right, I just had one stupid problem, so stupid I really don't feel like mentioning it. I got it now and I would like to extend my thanks to no2pencil for helping me out in this trivial case.
Was This Post Helpful? 0

#5 KingCuddles  Icon User is offline

  • D.I.C Regular

Reputation: 176
  • View blog
  • Posts: 496
  • Joined: 20-December 08

Re: 'www.url.com/Video.php?Video_ID=7' Can anyone explain?

Posted 14 February 2010 - 03:55 AM

OK, no2pencil is a respected member here (IMHO) and he has given you the answer with no questions asked.

DIC and its members tend to ask for some work to be done before we help, so the fact that he has provided code for you, and told you how to learn more should be enough...

EDIT: Sorry, you posted your last post while I was typing this, hopefully there are some things in my post which will help you :D

What you wanna do is:

Paste the code he provided at the top of your script somewhere, and then load the video based on the ID..

$video_id = $_GET[id];

echo "<embed src='http://www.mysite.com/viewvideo.php?id=' . $video_id . autostart='false' />"

//this is VERY basically what you want





Then create hyper links to the next video, in the following format.

<a href="http://www.mysite.com/viewvideo.php?id=XX">Next/Previous</a>

//the XX = the number of the next video, you could use [url="http://net.tutsplus.com/tutorials/php/how-to-paginate-data-with-php/"][b][u]pagination[/u][/b][/url] to do this, as this would prevent you having to create the link manually, check out that link for more info on pagination.

//you could also do something like..

$url = "http://www.mysite.com/viewvideo.php?id";
$video_id = $_GET[id];
$video_prev = $url . $video_id--;
$video_next = $url . $video_id++;

echo "<a href='$video_prev'>Previous</a>";
echo "<a href='$video_next'>Next</a>"; 


--

This combined with what no2pencil gave you, you should give you enough to start. I suggest that you build a test application with what we have shown you today, and come back and let us know if it works, if it dosnt we will make it :D.

BTW, Im sorry if any of my code is a little bit off, its 10:50 am, and I just woke up, lazy lie ins FTW.

This post has been edited by KingCuddles: 14 February 2010 - 04:03 AM

Was This Post Helpful? 0
  • +
  • -

#6 josh06  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 14
  • View blog
  • Posts: 139
  • Joined: 27-October 06

Re: 'www.url.com/Video.php?Video_ID=7' Can anyone explain?

Posted 15 February 2010 - 09:23 AM

What you could do is set up a database.
In this database you would have a table for videos and you wouldn't store the actual files in here, but you would store the links to the videos in here.
You would then have an id field which auto_increments everytime you add a URL into the table.

For example id 1 would go to someurl.avi or id 2 would go to example.avi
Then you would $_GET the id and check the database for that id. It would then provide you with the link for the file which you would use to embed.

A tiny example:
<?php
  
  if(!isset($_GET['id']){
     echo "Nothing in URL";
  }
  else{
     $vid_url = $_GET['id'];
     $sql = 'SELECT * FROM table WHERE id = "' . $vid_url . '" LIMIT 1';
     $result = mysql_query($sql) or die(mysql_error());
     $row = mysql_fetch_array($result) or die(mysql_error());
  
     // Got Link from Database.
  }
?>
   <a href="<?php echo $row['url'] ?>"><?php echo $row['vidName'] ?></a>



Hopefully that will help?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1