WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Report Generation in Microsoft Access from a MYSQL database
Categories : PHP, MySQL, Databases, MS Access Update Picture
Woody Stanford
Date : Feb 20th 2001
Grade : 3 of 5 (graded 8 times)
Viewed : 22075
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Woody Stanford
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

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
bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager
Categories : MySQL, PHP, MySQL, Complete Programs, 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
DDN FFA Network Script
Categories : PHP, MySQL, Complete Programs, HTML and PHP, Databases
Identify and log search engine access (spiders, robots, etc.) to a page.
Categories : HTTP, Environment Variables, PHP, MySQL, Databases
Education Center is a set of PHP-scripts to administer a corporate education and examination system via Internet/intranet written in PHP for MySQL.
Categories : PHP, Databases, MySQL, Complete Programs
A simple script to count and report hits and the last modification time of an HTML page. Requires MySQL support (other DBs should work too, except possibly mSQL).
Categories : HTTP, MySQL, PHP, Databases
Simple database class
Categories : PHP, PHP Classes, MySQL, Databases
mysql date/time converters
Categories : PHP, MySQL, Databases, Date Time
Pull Down Surfing - Surf on Change
Categories : Java Script, MySQL, HTML and PHP, PHP, Databases
myCSV-dump converts a simple CSV-flatfile-database into an MySQL-dump.
Categories : PHP, MySQL, Databases, Complete Programs
Web Self Service Resource Scheduler Using Session Variables under php4 includes Calendar building code - requires MySQL
Categories : PHP, Complete Programs, Calendar, MySQL, Databases
very cool guestbook that uses php, and mysql to store data. looks very nice. supports smilies / emoticons (SEG-Media V1.0)
Categories : PHP, Databases, MySQL
Authorize Me! An authentication script.
Categories : MySQL, Databases, Authentication, PHP
Multiple Search using PHP and Mysql
Categories : PHP, Databases, General SQL, 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.