MAY 30TH, 2008
By MOHAMMAD SAJJAD HOSSAIN
I have used DOMPDF in my project. But I was facing problem with Attachment. In FireFox it was working fine. But in Internet Explorer (I used IE 6) it ended with an error. In IE it was showing the download dialogue box offering the script page I used to generate the PDF file. When I tried to download the file it showed an error.
I searched the web and found no suitable solution. I followed the instruction given in http://www.corenettech.com/blog/ but it didn’t work :(. But I got an idea from this post. I started digging the code and have done following changes to PDFLib_Adapter class (available in DOMPDF_DiRECTORY/include/pdflib_adapter.cls.php).
I have removed the following line (line 829):
header("Cache-Control: private"); |
header("Cache-Control: private");
and added
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
{
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header("Content-Transfer-Encoding: binary");
header('Pragma: public');
header("Content-Length: ".strlen($data));
}
else
{
header("Cache-Control: private");
header("Content-Transfer-Encoding: binary");
header('Expires: 0');
header('Pragma: no-cache');
header("Content-Length: ".strlen($data));
} |
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
{
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header("Content-Transfer-Encoding: binary");
header('Pragma: public');
header("Content-Length: ".strlen($data));
}
else
{
header("Cache-Control: private");
header("Content-Transfer-Encoding: binary");
header('Expires: 0');
header('Pragma: no-cache');
header("Content-Length: ".strlen($data));
}
After
header("Content-type: application/pdf");
header("Content-Disposition: $attach; filename=\"$filename\""); |
header("Content-type: application/pdf");
header("Content-Disposition: $attach; filename=\"$filename\"");
That’s it! My code started working :).
Hope this will save your time of surfing the net ;).
APRIL 24TH, 2008
By MOHAMMAD SAJJAD HOSSAIN
Based on my last post on paging using PHP and MySQL, I have coded this class. It is very easy to implement and it will save your time. Here is a code snippet to show how simple to use it.
//include the class file
include('Pager.php');
//making connection to the database
mysql_connect('localhost', 'root', '');
mysql_select_db('test');
//prepare SQL
$sql = 'SELECT * FROM books';
//create an object of Pager passing the SQL
$pager = new Pager($sql);
//set the url. this is the current page
$pager->url = 'index.php';
//set number of rows. by default it is 10
$pager->rowPerPage = 5;
//build the pager
$pager->build();
//get paged data
$rows = $pager->getPagedData(); |
//include the class file
include('Pager.php');
//making connection to the database
mysql_connect('localhost', 'root', '');
mysql_select_db('test');
//prepare SQL
$sql = 'SELECT * FROM books';
//create an object of Pager passing the SQL
$pager = new Pager($sql);
//set the url. this is the current page
$pager->url = 'index.php';
//set number of rows. by default it is 10
$pager->rowPerPage = 5;
//build the pager
$pager->build();
//get paged data
$rows = $pager->getPagedData();
Click the download link given below for a copy of the class. It also includes an working example.

MARCH 13TH, 2008
By MOHAMMAD SAJJAD HOSSAIN
Date control is a combination of three drop downs with month, day and year valus. It can be used as an alternative to the date picker control. Suppose a user needs to select a date before/after 10 years. At this point selecting the date with a date picker will not be easy and time consuming. So, in this situation, this control may be helpful.

To customize you need you can configure it. Change the properties in date_control.js file.
How to use it?
1. Unzip the download
2. Link the date_control to the page you want to use it in.
3. Write this code where you want to place the control
<script language="javascript">
// getting the date control
getDateControl("name_of_the_field", "name_of_the_form");
</script> |
<script language="javascript">
// getting the date control
getDateControl("name_of_the_field", "name_of_the_form");
</script>
For more details see the demo.html file included in the download.
I have tested the code with Internet Explorer 6 and FireFox 2.X.X and it works fine.
You can download a copy from here: 