php dynamic link help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
edanlee
Forum Newbie
Posts: 15
Joined: Mon Mar 24, 2008 12:05 am

php dynamic link help

Post by edanlee »

hello all and thank you for your help with the community,

i'm kinda stuck and need some help.. let me begin by telling you what i want to do and then i'll ask you how i should approach the task...

i'm creating a website that will have video tutorials on 3d design... none of these videos will be user submitted all of them will be submitted by me.
i have all of the site coded except for the video section... what i want to do is have a rank table.. like say 0=guest, 1=registered, 2= gold member.
i want a page that will display all of the videos but only those that match the current users rank will be clickable. please look at this site to explain what i'm talking about.
http://movielibrary.lynda.com/html/modPage.asp?ID=560, if you look at that page you will see that some videos you can view and some you cannot untill you login.
all the videos will be stored in mysql with prolly about 3-4 fields: vid_id, title, src, catagory. when the link is clicked it will call the video by id and play it in a pop-up. but some videos can only be seen by gold members. i already have a pretty good login script being used. the current login script uses sessions and mysql.

how should i go about creating this video section... i dont neccesarilly need code but more a run down of what should take place. but code would also be nice... i cant afford much but i would be willing to pay some money if i needed to... i thank you for your time reading this and your time of solving my problem...

thank you,
Edanlee
edanlee
Forum Newbie
Posts: 15
Joined: Mon Mar 24, 2008 12:05 am

Re: php dynamic link help

Post by edanlee »

can anyone please help me with this.. atleast explain how to do the whole .php?vid=12
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: php dynamic link help

Post by aceconcepts »

What is your objective?

It sounds like you want to know how to list user-specific links and then you talk about url variables.

Explaid in brief what you're trying to do.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: php dynamic link help

Post by John Cartwright »

Simply put, .php?vid=12

Code: Select all

$vid = $_GET['vid']; //12
edanlee
Forum Newbie
Posts: 15
Joined: Mon Mar 24, 2008 12:05 am

Re: php dynamic link help

Post by edanlee »

i dont much understand what your telling me to do... but what i want to do is have a pop up that will play a movie based on what link they click... so the pop up will always have the same url but the variable will be defined by the link... like popup.php?vid=12, popup.php?vid=13, and so forth all based on what link they clicked...
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: php dynamic link help

Post by John Cartwright »

when listing the results, simlpy append the movie id to the url

Code: Select all

while ($row = mysql_fetch_assoc(... )) {
   echo '<a href="movie.php?id='. $row['id'].'">'. $row['title'].'</a> <br >';
}
Then on your movie page, you provide the $_GET['id'] from the link into your query

Code: Select all

$id = isset($_GET['id']) ? intval($_GET['id']) : 0; //basic sanitation
$sql = 'SELECT * FROM movies WHERE id = '. intval($id);
 
$result = mysql_query($sql) or die(mysql_error());
// etc
Clearer?
edanlee
Forum Newbie
Posts: 15
Joined: Mon Mar 24, 2008 12:05 am

Re: php dynamic link help

Post by edanlee »

that is exactly what i was looking for... thank you so much
AMCH
Forum Commoner
Posts: 31
Joined: Sun Mar 30, 2008 4:39 pm

Re: php dynamic link help

Post by AMCH »

I see you have what you need now but I was a little confused by your link here, this is an asp page but you are trying to use php on it? :|

AMCH

PS: Upon re-examination of the article I have realised that this is not your page but an example of the functionality you require using php instead of asp. It's late! :?

:lol:
edanlee
Forum Newbie
Posts: 15
Joined: Mon Mar 24, 2008 12:05 am

Re: php dynamic link help

Post by edanlee »

yes thats the gameplan is to have something similar to that website. if i can tackle it. but thank you for your help.

Edanlee
kryles
Forum Contributor
Posts: 114
Joined: Fri Feb 01, 2008 7:52 am

Re: php dynamic link help

Post by kryles »

this is to show the movie, but where was the rank part taken care of? Wouldn't you use a query to check if the user has access to that video?
edanlee
Forum Newbie
Posts: 15
Joined: Mon Mar 24, 2008 12:05 am

Re: php dynamic link help

Post by edanlee »

kryles wrote:this is to show the movie, but where was the rank part taken care of? Wouldn't you use a query to check if the user has access to that video?
well i just assumed i would have to come up with that part on my own... i already have a login system that uses sessions... i guess i would have to register the rank from the users database entry and using a if statement check to see if the users rank matches the rank required for the movie and if not then display a error.

edanlee
Post Reply