0

I have a button and if I click on that button then there are more than one html file store in folder should be show matched with database.

My code are:

<?php
include("connection.php");
extract($_REQUEST);

 $query=mysql_query("select * from fad_record where t_id='$word'") or die(mysql_error());
while($result=mysql_fetch_array($query))
{
extract($result);
        ob_start();
        include("3_day_notice_fad/$fad_html_name");
        $html_content = ob_get_contents();
        ob_end_clean();
        echo $html_content;
}
?>

But when code runs then all files are showing in one file. But I want all different file open in different tab.

Patrick Simard
  • 2,294
  • 3
  • 24
  • 38
user3526766
  • 93
  • 1
  • 3
  • 16

1 Answers1

1

This cannot be done using only PHP, opening tabs is a browser option so you need a client side script. jQuery can do that. You should start by creating an ajax call to the PHP and open the result in a new tab. Although, users with spam blockers or with a high-security setting will block that. I would advise against such a feature and find a better way to do this. Perhaps use the jquery UI tab system?

https://jqueryui.com/tabs/

Take a look at it and see if you can use that in your logic


Convert HTML to PDF

DOMPDF : php class that wraps the html and builds the pdf. Works good, customizable (if you know php), based on pdflib, if I remember right it takes even some CSS. Bad news: slow when the html is big or complex.

HTML2PS: same as DOMPDF, but this one converts first to a .ps (ghostscript) file, then, to whatever format you need (pdf, jpg, png). For me is little better than dompdf, but has the same speed problem.. but, better compatibility with CSS.

Those two are php classes, but if you can install some software on the server, and access it throught passthru() or system(), give a look to these too:

wkhtmltopdf: based on webkit (safari's wrapper), is really fast and powerful.. seems like this is the best one (atm) for converting html pages to pdf on the fly; taking only 2 seconds for a 3 page xHTML document with CSS2. It is a recent project, anyway, the google.code page is often updated.

htmldoc : This one is a tank, it never really stops/crashes.. the project looks dead since 2007, but anyway if you don't need CSS compatibility this can be nice for you.

Patrick Simard
  • 2,294
  • 3
  • 24
  • 38
  • You cannot send more than 1 file in response to an HTTP request. What I would suggest is zip the file in a single file and return that. https://stackoverflow.com/questions/1754352/download-multiple-files-as-zip-in-php – Patrick Simard Jul 23 '17 at 18:57
  • Basically I have some html file and I have to convert them into pdf and then download. But don't know, how to convert html file into pdf. So I added javascript print() in html file, so that if html file opens in browser then click on button, I can save them in pdf. But it works with single html. But if you please tell me process of convert html to pdf then I can save them in zip file. – user3526766 Jul 23 '17 at 19:03
  • Will post a new answer for this one. Please edit your question with how to convert HTML to PDF so I am not off topic lol – Patrick Simard Jul 23 '17 at 19:08
  • 1
    Made an edit instead ;-) There's also a few online API on google but they're not free. Best to use a GPL library. I used wkhtmltopdf on one of my projects but you need server privileges to get it working. – Patrick Simard Jul 23 '17 at 19:11