|
|
|
PHP is great for a lot of things, but report generation is NOT one of them (compared to Crystal
Reports or other report generators). I really like Microsoft Access's report environment, but its
a royal pain in the butt to tranfer data from a MySQL database to Access, especially if you
need to do it multiple times (like you have to with real life reports). Here is the simplest way I
know how to do it FULLY AUTOMATICALLY
<b>Instructions:</b><br>
(1) mount the following script on your PHP server<br>
(2) modify it for your particular situation<br>
(3) debug it (i.e. invoke it from a browser until it comes back with "100 success")<br>
(4) download the zip file reportsynch.zip (can be downloaded from
http://www.stanfordsystems.com/downloads/reportsynch.zip)<br>
(5) unzip and install on a Microsoft Windows machine<br>
(7) run the program ReportSynch.exe and click the Details button; enter the required
connection info and Save.<Br>
(6) In Microsoft Access, make a database with the table(s) you are transfering.<br>
(7) run ReportSynch and click Synch Now.<br>
(8) You now have a copy of the MySQL table in your Access table. Make the reports you need
in Access or in Crystal, or whatever report designer you have (that will connect to local Access
database).<br>
(9) Wheneve you want to run a set of reports, run the ReportSynch utility to download a
current version of the MySQL data.<br>
Here is the PHP script...
<?
//convert-to-access-date: takes a mysql date and converts it to a format embeddable in
Access SQL
function ctad($dt)
{
$yr=strval(substr($dt,0,4));
$mo=strval(substr($dt,5,2));
$da=strval(substr($dt,8,2));
return "$mo/$da/$yr";
}
//MS Access escape string function
function csql2($s)
{
for ($a=0;$a<strlen($s);$a++)
{
$c=substr($s,$a,1);
if ($c=="\"") $c="\"\"";
if ((ord($c)==10)||(ord($c)==13)) $c=":";
$s2.=$c;
}
return $s2;
}
$con = mysql_connect(localhost,"your_username","your_password");
if ($con==NULL)
{
echo("301 Couldn't connect to MySQL\n\n");
exit(-1);
}
$db = mysql_select_db("your_database_name",$con);
$fptr=fopen("export.txt","w");
//The example table is "po" (or purchase order table). I selected this one from one of many
because the filed list is short, but it has all the most common data types (i.e. string, integer,
byte, date)
//substitute you own values. Also remeber that the Access SQL generates DOES NOT create
the table; you must create it yourself from inside Access.
fputs($fptr,"delete * from po;\n");
$res=mysql_query("select poid, vendorid, toline1, toline2, toline3, toline4, email, podate,
received from po order by poid",$con);
$nr=mysql_num_rows($res);
if ($nr>0)
{
for ($a=0;$a<$nr;$a++)
{
$row=mysql_fetch_row($res);
$poid=intval($row[0]);
$vendorid=intval($row[1]);
$toline1=csql2($row[2]);
$toline2=csql2($row[3]);
$toline3=csql2($row[4]);
$toline4=csql2($row[5]);
$email=csql2($row[6]);
$podate=ctad($row[7]);
$received=intval($row[8]);
fputs($fptr,"insert into po (poid, vendorid, toline1, toline2, toline3, toline4, email,
podate, received ) select $poid as e1, $vendorid as e2, \"$toline1\" as e3, \"$toline2\" as
e4,\"$toline3\" as e5, \"$toline4\" as e6, \"$email\" as e7, #$podate# as e8, $received as
e9;\n");
}
}
mysql_free_result($res);
fclose($fptr);
echo("100 success");
?> |
|
| mediaCat-GTK v2.0.0 - an mp3/cd/dvd cataloging utility written in php-gtk which interfaces with mysql and ms access (or db supported by PHP's Unified ODBC Functions) Categories : PHP, MySQL, MS Access, Utilities, Databases | | | This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server. Categories : Databases, MySQL, Complete Programs, PHP, Databases | | | bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager Categories : MySQL, PHP, MySQL, Complete Programs, Databases | | | Point and Click Interface ala MS Access for creating SQL statements. Categories : MySQL, Complete Programs, General SQL, PHP, Databases | | | Displaying records of database in more than one page (paging) Categories : Databases, MySQL, PHP | | | Message of the Day - Random Message (Needs MySQL!) Categories : Databases, HTML and PHP, PHP, MySQL | | | Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs. Categories : Databases, PHP, MySQL, Complete Programs | | | Cut your MySQL Connections to 1 line of code Categories : PHP, Beginner Guides, Databases, MySQL | | | phpAds, a complete banner and ad management system with detailled tracking and stats. Categories : MySQL, Complete Programs, Ecommerce, PHP, Databases | | | Automatically printing the contents of an sql table in MySQL. Categories : MySQL, PHP, HTML and PHP, Databases | | | Email a user with out exposing email address Categories : PHP, Databases, MySQL, Email | | | A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL | | | Tropicalm Genetree Family (MySQL based family tree) Categories : PHP, Interfaces, Databases, MySQL, Complete Programs | | | mysql_escape_string Categories : PHP, MySQL, Databases, Strings | | | http://phpMySearch.web4.hm - The phpMySearch search engine system is a completeworld wide web indexing and searching system for a small domain or intranet. Categories : Search Engines, PHP, Databases, MySQL | |
| | | | Heiko Schwarzenberg wrote : 578
I tried to download the reportsynch.zip but the link is broken. Has anyone already downloaded the file and send it to me?
Thanks, Heiko
| | | | Andy Jackson wrote : 579
It`s easier just to use ODBC and linked tables to run your reports.
| | | | Dave Bean wrote : 581
I`ve tried generating html reports with Access and while it has nice features it does not seem to cary the cell colors to the html report. Basically I gave up and went back to hand coding the html reports with PHP. Does anyone know of a reasonably priced HTML report generator?
Thanks - Dave
| | | | Ap Muthu wrote :756
Try NetAutor from http://netautor.org and TurboPHP from http://www.turbophp.com
DeltaPHP is also a good one page generator.
| |
|
|
|