echoing the content of a document

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ssharifi
    New Member
    • Apr 2010
    • 11

    echoing the content of a document

    hi

    i want to echo the content of a pdf or word document(which is in my db) in the web page.but i dont want it to be displayed as pdf format,as it is in this code
    Code:
    <?php
    require_once('config/database.php');
    $rscRS = mysql_query("SELECT * from upload WHERE id=" .  $_GET['id']) or die(mysql_error($rscDb));
    $arrRow = mysql_fetch_assoc($rscRS);
    header('Content-Type:  application/pdf');
    header('Content-Disposition: inline; filename='.$arrRow['name']);
    header('Content-Size: '.strlen($arrRow['content']));
    echo  $arrRow['content'];
    ?>
    i want to do it so that admin can edit every page as he likes with uploading the content. because with text area it is very limited.
    for example if in .doc or .pdf file the first sentece is "it is hot today" i want to echo the exact format or if there is a picture...
    is it a correct way for editing the web pages?if it is yes how should i change the code and if it is no how can i do it?
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    So, just to make sure I understand you correctly, you want to display the contents of a PDF or DOC file in the web page; so that the text and/or images inside the file are displayed as they are in the file in a HTML page? And you want the administrator to be able to edit them as if they were using Word or Acrobat?

    If so then no, that is most definitely not the correct way to create, add or edit a webpage. Webpages are usually created using HTML. PHP is typically used to dynamically generate the HTML using data from a database. - Storing the pages as PDF or DOC documents would require you to convert them to HTML on every request, and you would never find a converter that converts them 100% accurately (especially not the DOC files).

    You would be better of uploading HTML templates, and having PHP dynamically fill them in. That is what pretty much all PHP driven webpages do; pull data from a database, fill in a HTML template and send that to the browser.

    Comment

    • ssharifi
      New Member
      • Apr 2010
      • 11

      #3
      hi,thanks for the advice,i meant for example when i give the site i have written to the admin of site he wants to fill it as he like without using the editors like dreamweaver,bec ause it is educational site for most of the pages they have a predefined apearance.but for example for the first page maybe once the admin wants to add a description and a picture,and after sometme he wants to change the appearance and content and put 3 pictures,theref ore i cant use textfied,text area and uploading image to let him fill in the site.i thought maybe he could write the content including pictures and... in a document and upload that and i show that as the content of the site,for this mean the general way is html template?if it is yes,i will search about it and if i had question,i put my question about it here;because i havent heard any thing about it

      Comment

      Working...