Re: help me in creating tables on the fly
| From: | Jasper Bryant-Greene | Date: | Wed, 12 Oct 2005 08:47:39 +0000 |
| Subject: | Re: help me in creating tables on the fly | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-223945@lists.php.net to get a copy of this message | ||
Suresh Pandian wrote:
im currently working on creating musical forum..... i need to create tables for every song uploaded on the fly to save the comments and rates entered by the viewers. im unable to create tables on the fly......... can anyone know how to create tables on the fly .........plz tell me ......... Also, can u tell me the way to how to play the song using php...... i uploaded the songs to mysql database... if u know the same kind of work anywhere in the net as tutorials and help .........plza tell me the URL........AHHH! Don't create a table for every song!!!! Have a
songs table containing all of the songs. Something like:
CREATE TABLE songs (songID INT UNSIGNED NOT NULL AUTO_INCREMENT, artist VARCHAR(50) NOT NULL, title VARCHAR(50) NOT NULL, PRIMARY KEY(songID));
(simplified) and another table comments like this:
CREATE TABLE comments (commentID INT UNSIGNED NOT NULL AUTO_INCREMENT, songID INT UNSIGNED NOT NULL, comment TEXT NOT NULL, PRIMARY KEY(commentID), KEY(songID));
and another ratings like this:
CREATE TABLE ratings (ratingID INT UNSIGNED NOT NULL AUTO_INCREMENT, songID INT UNSIGNED NOT NULL, rating TINYINT UNSIGNED NOT NULL, PRIMARY KEY(ratingID), KEY(songID));
That's why it's called a *relational* database. If you're using InnoDB you can even define the relations between the tables using foreign keys. Go to http://dev.mysql.com/doc/en/mysql/ and have a good read of the MySQL manual, it will be very helpful for you.
Please don't just copy-paste the above table definitions, they're meant to be modified to suit your needs.
I'll leave your other question to be answered by someone with experience of streaming audio from PHP, as I've never had occasion to do that.
--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/