Results 1 to 8 of 8
-
09-23-2013, 02:27 AM #1Newbie
- Join Date
- Sep 2013
- Posts
- 15
How to use a filename as a hyperlink
HEY!
I have in the Database where one field is the file name, i want to use that file name as a hyperlink , such that when you click on it, you should be able to download the file.
<?php
//capture search term and remove spaces at its both ends if the is any
$searchTerm = trim($_GET['keyname']);
//check whether the name parsed is empty
if($searchTerm == "rinex_file")
{
echo "Enter name you are searching for.";
exit();
}
//database connection info
$host = "localhost"; //server
$db = "r"; //database name
$user = "m" //dabases user name
$pwd = "c"; //password
//connecting to server and creating link to database
$link = mysqli_connect($host, $user, $pwd, $db);
//MYSQL search statement
$query = "SELECT * FROM rinexo WHERE rinex_file LIKE '%$searchTerm%'";
$results = mysqli_query($link, $query);
/* check whethere there were matching records in the table
by counting the number of results returned */
if(mysqli_num_rows($results) >= 1)
{
$output = "";
while($row = mysqli_fetch_array($results))
{
$output .= "rinex version: " . $row['rinex_version'] . "<br />";
$output .= "program: " . $row['pgm'] . "<br />";
$output .= "date: " . $row['date'] . "<br />";
$output .= "maker name: " . $row['marker_name'] . "<br />";
$output .= "maker number: " . $row['marker_no'] . "<br />";
$output .= "observer: " . $row['observer'] . "<br />";
$output .= "agency: " . $row['agency'] . "<br />";
$output .= "position_X_Y_Z: " . $row['position_X_Y_Z'] . "<br />";
$output .= "delta: " . $row['delta'] . "<br />";
$output .= "wavelength: " . $row['wavelength'] . "<br />";
$output .= "rinex file: " . $row['rinex_file'] . "<br />";
}
echo $output;
}
else
echo "There was no matching record for the name " . $searchTerm;
?>
here the rinex_name is the one that needs to have an hyper linkLast edited by madu; 09-23-2013 at 02:36 AM. Reason: needed to add more details
-
09-23-2013, 11:30 AM #2Need Moar KAWFEE
- Join Date
- Apr 2003
- Location
- Atlanta, Jawja
- Posts
- 3,074
Is the file stored in the database (bad idea, if it is) or stored as an actual file on the server itself? The answer to this determines how we answer.
Doug Hazard - "retired" Web Hosting Master
* Full Stack (Web/WP) Dev for The Catholic Diocese of Richmond (160+ sites)
* Sports Photographer, Media Personality and CFB Historian
* Tech Admin for several Sports Networks/Sites
-
09-24-2013, 04:01 AM #3Newbie
- Join Date
- Sep 2013
- Posts
- 15
HEY!
yeah the file is stored in the database( a directory) as of now, after which it will be deployed on to a server, i need to be able to use the file as a hyperlink so that one can download it on to thier systems.
-
09-24-2013, 10:37 AM #4Need Moar KAWFEE
- Join Date
- Apr 2003
- Location
- Atlanta, Jawja
- Posts
- 3,074
You might want to re-think doing that. One of the best decisions I ever made was to stop storing files in the database. You can still mask their location via PHP and MySQL, but you need to consider not utilizing database stored files.
That being said, there's a pretty basic tutorial for downloading the files that you have stored. You need to learn about "MIME types".
Have a peek at http://php.about.com/od/phpbasics/ss/mysql_files_6.htm (again, VERY basic, but should give you a good starting point)Doug Hazard - "retired" Web Hosting Master
* Full Stack (Web/WP) Dev for The Catholic Diocese of Richmond (160+ sites)
* Sports Photographer, Media Personality and CFB Historian
* Tech Admin for several Sports Networks/Sites
-
09-24-2013, 11:59 AM #5Newbie
- Join Date
- Sep 2013
- Posts
- 5
This really nice post. keep on posting this kind of helpful posts. thumbs up
-
09-24-2013, 11:58 PM #6Newbie
- Join Date
- Sep 2013
- Posts
- 15
hey!
the link that u sent is very good! but doesnt serve my purpose, here is what i really want. on the template i want a hyperlink to the file abc.03h , when i click on this i should be able to download this on the system. how do i get the file names from the server on the template for me to choose to click to download?
-
09-25-2013, 10:23 AM #7Need Moar KAWFEE
- Join Date
- Apr 2003
- Location
- Atlanta, Jawja
- Posts
- 3,074
madu, the link I provided actually covers EXACTLY what you need. You could also google "Doownload binary file stored in mysql"
Doug Hazard - "retired" Web Hosting Master
* Full Stack (Web/WP) Dev for The Catholic Diocese of Richmond (160+ sites)
* Sports Photographer, Media Personality and CFB Historian
* Tech Admin for several Sports Networks/Sites
-
09-27-2013, 02:20 AM #8Newbie
- Join Date
- Sep 2013
- Posts
- 15
http://www.computerhope.com/issues/ch001113.htm i need to implement this concept!
Similar Threads
-
Hyperlink help!
By dannym031292 in forum Web Design and ContentReplies: 2Last Post: 12-30-2007, 04:38 PM -
Hyperlink Problem
By Melamorie in forum Hosting Security and TechnologyReplies: 2Last Post: 04-18-2007, 10:30 PM -
simple hyperlink help
By hoachen in forum Programming DiscussionReplies: 8Last Post: 08-11-2005, 06:44 PM -
POST w/ HYPERLINK
By tylerg in forum Programming DiscussionReplies: 5Last Post: 07-21-2004, 02:28 PM -
Signature Hyperlink
By HostBidder in forum WHT Announcements, Feedback and QuestionsReplies: 6Last Post: 03-18-2004, 10:31 PM