Hi all, i have a table in db which contain some pdf and docx files.
Am trying to display it in a way, so that when the user click on it, it will load the pdf and/or docx file from db in another/same window.

this is what i have done so far:

<?php
        $query = "SELECT image_file, note_title, note_commt FROM notez WHERE svreg = '".$svreg."'";
        $result = mysql_query($query) or die('Error, query failed');
        while(list($image_file, $note_title, $note_commt) = mysql_fetch_array($result))
        { ?>

        <img src="<?=$image_file?>" width='30' height='30' class='thumbnail' title='<?=$title?>'>                                                                      
        <?php } ?>
Member Avatar for iamthwee

I would use pdf.js to load the pdf.

Not too sure about docx though.

thank for the code IIM, i tryed it

echo '<pre>';
//echo "starting\n";
                    set_time_limit (30); //to allow time for Word to load.
                    $word = new COM("word.application") or die ("Could not initialise MS Word object.");
                    echo "COM instantiated\n";
                    $word->Application->Visible = False; 
                    echo "set visibility to false\n";

                    $doc = "src='userimages_doc/1364905979.3535.doc'";
                    $document = reapath($doc);
                    //if (is_readable($document)
                    echo "Document exists and is readable \n";
                    //else:
                    if(!is_file($document)):
                    echo "Document does not exist\n";die();
                    else:
                    echo "Document is not readable\n"; die();
                    endif;
                    //endif;
                    $word->Documents->Open( $document ); 
                    echo "Document opened\n";
                    // Extract content. 
                    $content = $word->ActiveDocument->Content; 
                    echo "test\n----------\n";
                    print_r($content);
                    echo "test\n----------\n";
                    echo "Extracting string value of content\n";
                    $content = (string) $content;
                    echo "test\n----------\n";
                    echo $content;
                    echo "test\n----------\n";

                    echo $content; 

                    $word->ActiveDocument->Close(false); 
                    echo "Closed Document\n";
                    $word->Quit(); 
                    //echo "Quit Word \n"
                    $word = null; 
                    unset($word);

                    //}

but i keep getting this error

Fatal error:  Call to undefined function reapath() in D:\xampp\htdocs\auto-habari\admin\userindex\vehicles\veh_over_view.php on line 441

i do not know if it have anything to do with this code

 $doc = "src='userimages_doc/1364905979.3535.doc'";

typo for realpath()

should test on the dir name only

    $doc="userimages_doc/1364905979.3535.doc";
    $dir=pathinfo($doc);
    $document=realpath($dir['dirname']).DIRECTORY_SEPARATOR.$dir['basename'];

thanks pzuurveen for the help, this is what i get

COM instantiated
set visibility to false
Document exists and is readable 
Document is not readable

can you pls tell me what it means, cos am not sure if the scprit is working

if (is_readable($document)) {
    echo "Document exists and is readable \n";
    }
else {
    if(!is_file($document)) {
        echo "Document does not exist\n";
        die();
        }
    else {
        echo "Document is not readable\n"; 
        die();
        }
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.