Help with PHP/MySQL

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
kgpri2
Forum Newbie
Posts: 4
Joined: Mon Apr 17, 2006 6:34 am

Help with PHP/MySQL

Post by kgpri2 »

Hi all,

I'm creating a website that will (primarily) have thousands of videos. Rather than using a template to create a new HTML page for each new video(i.e. to avoid having to create thousands of HTML pages), I want to use PHP so that clicking a particular video link will 1. open the (one and only) video player page and 2. get the relevant video file. I've configured PHP/MySQL/Apache/phpMyAdmin and have them running smoothly. I'm not sure if I need to create a database in MySQL to hold the videos(and/or their details) or whether PHP code alone will be sufficient.

Thanks guys
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Yes you'll want a database to do it correctly. The database is for storing information... the PHP code contains the logic for handling it.
kgpri2
Forum Newbie
Posts: 4
Joined: Mon Apr 17, 2006 6:34 am

Post by kgpri2 »

Ok cool.

What fields do I need to have on the videos table in the database?

Thanks
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

That really depends upon what information you're going to need. What sort of videos (hmm.. actually lets not :P).

Lets say they were actual movies you might want several tables to hold information like what studio the moview was shot at, who produced it. Then in the main table specific to that movie you might want release date, movie name, stars, certificate etc.

You need to decide what information you're going to need to have access to.
kgpri2
Forum Newbie
Posts: 4
Joined: Mon Apr 17, 2006 6:34 am

Post by kgpri2 »

Thanks for your help d11wtq.

Ok, let me assure you our project is G rated. :)

I only really need to record the title and description for each video. So one table would be sufficient right?

The question I really need an answer to is, does the database actually hold the file or do you only enter into each field the location/address of the video file? How do you do this? Is there a relevant function in phpmyadmin?

Thanks again
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

kgpri2 wrote:Thanks for your help d11wtq.

Ok, let me assure you our project is G rated. :)

I only really need to record the title and description for each video. So one table would be sufficient right?

The question I really need an answer to is, does the database actually hold the file or do you only enter into each field the location/address of the video file? How do you do this? Is there a relevant function in phpmyadmin?

Thanks again
Sounds like one table should be enough yes.

It's possible to store binary data in the database yes (the video) but it's not a good idea if you can avoid it since it's pretty slow and just creates extra work when transferring that data agin with the correct headers.

The best thing to do is to rename the file on upload, then store it's path in the database.
kgpri2
Forum Newbie
Posts: 4
Joined: Mon Apr 17, 2006 6:34 am

Post by kgpri2 »

Thanks again.

Ok, so does the field that contains the video paths need to have settings so that the database knows it is a path (and not just text)?

Really elementary stuff, I know. But I'm having trouble finding tutorials/info that specifically relates to this... Any recommendations?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

kgpri2 wrote:Thanks again.

Ok, so does the field that contains the video paths need to have settings so that the database knows it is a path (and not just text)?

Really elementary stuff, I know. But I'm having trouble finding tutorials/info that specifically relates to this... Any recommendations?
A field of type varchar should be sufficient. PHP will read that data as a string which it can place into the web page in a hyperlink, or an embed or such like.
Post Reply