user3526766 user3526766 - 1 year ago 69
Javascript Question

Download more then one file at the same time

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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download