I created Ajax based dependent dropdown list and based on the selected item I selected table from database and displayed html table as output.

Now I want to generate hyperlink for each row of html table .This hyperlink is used to access public files based on the fid

I think i cannot use views because i am generating html table based on selected item from dropdownlist

I would be more thank full if anyone can share some ideas

  • Still you can make use of views here. Make the drop-down list as an exposed filter and select the style under FORMATE as table Commented Mar 10, 2014 at 14:06

1 Answer 1


If you have custom code that generates the table then it should be easy to output the link to files as well.

I assume you are looking for info on how to get the link to the file having your file id from the database.

You will need this: Given a File ID (fid) how can I get the HTML that represents that fid?

EDIT: After you provided some sample code I was able to figure out what you need:

You need a slash in front of drupal.

<a href=\"/drupal/sites/default/files/" . $data->FileName . "\">
  • Thanks for your reply.I have filename.using filename i have set path to public files as shown while($data = $result->fetchObject()){ // Fill the table rows $rows[] = array( $data->Title, $data->Year, "<a href=\"drupal/sites/files/" . $data->FileName . "\">" . $data->FileName . '</a>' This generates filename as link in html table but path is wrong .Any idea how to set path to public files.I am not sure what i am going is correct way or not .My main idea is to select row from html table and read and download public excel file.plz share your thoughts &ideas
    – Naveena
    Commented Mar 12, 2014 at 13:41
  • can you post a print_r of your $data object? print_r($data);
    – NickO
    Commented Mar 12, 2014 at 17:11
  • @NickOwhile($data = $result->fetchObject()){ $rows[] = array( $data->AuthorsList, //$data->FileName, "<a href=\"C:/xampp/htdocs/drupal/sites/files/".$data->FileName.'</a>'shows file name with link but path to access file is wrong ); } $output = theme_table( array( "header" => $header, "rows" => $rows, "attributes" => array(), "sticky" => true, "caption" => "", "colgroups" => array(), "empty" => t("Table has no row!") // The message to be displayed if table is empty ) ).theme("pager"); return $output; plz ask if its not clear
    – Naveena
    Commented Mar 13, 2014 at 8:07
  • I asked to see the result of printing the $data object. Can you change your code to while($data = $result->fetchObject()){ print_r($data);exit();} This will print the first raw $data object and you will see the actual fields and values available.
    – NickO
    Commented Mar 13, 2014 at 11:26
  • stdClass Object ( [Bib_ID] => 1 [AuthorsList] => H.K. Ciezki,G. Adomeit [Title] => Shock-tube investigation of self-ignition of n-heptane-air mixtures under engine relevant conditions [Journal] => Combustion and Flame [Year] => 1993 [CommonProperties] => equivalence ratio, temperature,ignition delay [FileName] => C&F_Dagaut_1995_Fig 1A_Pg134-97-03.xls is the raw data after i execute print_r(data).I have filename.
    – Naveena
    Commented Mar 13, 2014 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.