I am using the Data module in Drupal 7, and I have created a view which shows my table. I have a blob in my table and this is filling my page with content.

Is there any way that I can get the blob to display as a link, and the file must be downloaded when clicked?


Fixed the problem by doing this

if($vars['fields'][$field] == 'content')
         $field_output = "<form action=\"download.php\"      
        <input  type=\"submit\" name=\"download\" value=\"Download\"> 
            <input type=\"hidden\" name=\"did\" value=\"$num+1\"> 


and download.php needs to have something like this


    $table = 'tablename';
    $download_id = $_POST['id'];
    $q="SELECT * FROM {$table} where id = $download_id";
    $link = mysqli_connect(...);
    $res = mysqli_query($link,$q);
   $row = mysqli_fetch_assoc($res);
    $id = $row['id'];
    $name = $row['name'];
    $status = $row['status'];
    $content = $row['content'];
    header("Content-type: required type");
    header("Content-Disposition: attachment; filename=$name");
    echo $content;
   echo "Cannot download";}


Now I wish to know how to to access tables in a different database than the default drupal database mentioned in settings.php.I added another database in the settings.php which has the required table but I am not able to adopt tables from there.(They do not show up in the orphaned tables list).Is there a place where I can change so that the data module only sees the new database and not the default database

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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