By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,985 Members | 1,712 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,985 IT Pros & Developers. It's quick & easy.

The trouble with PHP Dynamic links

P: n/a
On my website, I have a lot of downloadable files. I have created a
database table which will hold things like the file name, the
filesize, the playtime, etc. I also have created a field that is named
'location'.
Question: How or is there a way to make the data in that field a
hyperlink to the files location for download?
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Mr Tone... wrote:
On my website, I have a lot of downloadable files. I have created a
database table which will hold things like the file name, the
filesize, the playtime, etc. I also have created a field that is named
'location'.
Question: How or is there a way to make the data in that field a
hyperlink to the files location for download?


you'll need to be a bit more clear. you want to have a 'location' field
which is a URL to a file to download?

sounds like you can just do this with some PHP or MySQL code when you add
the record:

INSERT INTO files (fname, fsize, playtime, location)
VALUES ('bobo.mpg', '239495823', '1800',
'http://www.mydomain.com/files/bobo.mpg');

--
I am not an ANGRY man. Remove the rage from my email to reply.
Jul 17 '05 #2

P: n/a
Mark wrote:
Mr Tone... wrote:

On my website, I have a lot of downloadable files. I have created a
database table which will hold things like the file name, the
filesize, the playtime, etc. I also have created a field that is named
'location'.
Question: How or is there a way to make the data in that field a
hyperlink to the files location for download?

you'll need to be a bit more clear. you want to have a 'location' field
which is a URL to a file to download?

sounds like you can just do this with some PHP or MySQL code when you add
the record:

INSERT INTO files (fname, fsize, playtime, location)
VALUES ('bobo.mpg', '239495823', '1800',
'http://www.mydomain.com/files/bobo.mpg');

Assuming you don't want to flood your DB with a bunch of repeated info, just
keep the "different" info in the DB and build the URL on the output side when
you format your page.

So assuming the "HTTP://www.mydomain.com/" is present in all URLs, then location
can contain just the subdirectory which contains the file in question.

Your INSERT would then look like:
INSERT INTO files (fname, fsize, playtime, location)
VALUES ('bobo.mpg', '239495823', '1800', 'files');

and you build your URL using the literal HTTP string we took out, the location,
a final "/" and then the fname column. You could even use the $_SERVER info to
create the HTTP string, probably. Minimizing the crap you keep in the DB will
help keep it running efficiently and I/O is the usual bottleneck for any system.

CJP

--
Christopher J Pomasl Suse Linux 9.0
Senior Software Engineer Starband 360 4/68
Computer Associates SPEBSQSA, Lead/Bari, SOR
IBM Certified Specialist - DB2 UDB V6/V7 User
IBM Certified Solutions Expert - DB2 V7 Family Application Development
IBM Certified Solutions Expert - DB2 UDB Database Administration for OS/390
Always remember, you are unique...just like everyone else.

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.