Get data from mysql and display in .epub format using php - php

I want to get data from mysql and display in .epub format using php, since am very new php (Codeigniter) & don't know about ePub (one of eBook format), please can some one help me to achieve this. What is the logic or the process need to follow.
Thanks in Advance.

You should output the data of the SQL database into XHTML files, and also keep record of which XHTML files you've written. With such output, you could use an EPUB creator tool manually or call it automatically. Since PHP is able to create zip files, all of this can be done within PHP. In case your question is still unsolved and you want such a PHP based EPUB creation software (or a workflow with a separate EPUB creator tool to call), just let me know, I would probably develop such a solution (licensed under GNU AGPL).

Related

PHP to MySQL and Google sheet?

A few months ago, my supervisor needed me to create a form to collect some data - at the time, the most sensible thing to do was just to whip together a Google Form, no problem. Now it turns out that the data collection program needs to expand, and it makes more sense to direct the form to a MySQL database (using PHP) instead - again, no problem, already done. However, for reasons I won't elaborate on here, my supervisor still wants that data to go to the original Google Sheet as well.
My question - is it possible to submit form data to two separate sheets when one is a MySQL table and the other is a Google Sheet?
Thanks!
I know that feel bro ;)
There's some resources to handle boss requests:
PHPExcel Class is a library written in pure PHP and providing a set of classes that allow you to write to and read from different spreadsheet file formats, like Excel (BIFF) .xls, Excel 2007 (OfficeOpenXML) .xlsx, CSV, HTML...
You will need an script to process the outputs.
Excel / CSV > MySQL
MySQL > Excel / CSV
If you need directly to work with Google Docs, you will have to follow the previous steps and play with the following project:
php-google-spreadsheet-client is a library that provides a simple interface to the Google Spreadsheet API.
You will need to store data in MySQL and pass it to Google.
Second idea:
If your boss neet it NOW, you can give a chance to Zapier and do it fast. If you don't need a very fast sync time, it can be a good free option.
I hope it helps :)

HTML with JScript to read/write XLS file

Very sorry if this is not in the right place etc. I have been researching this for a while but its raised more questions!
I have developed a spreadsheet which I use to set a teams duties for a shift. There are 5 teams, each with staff which can change day to day.
the spreadsheet works fine, but its too complicated for some users. I am therefore trying to develop a straightforward web based form.
All the data is on the spreadsheet, held on a network drive (essentially locally).
I need to be able to have several combo/select boxes which get their values from a range of cells from the XLS. Along with the ability to output the final selections to a XLS sheet.
Finally, it needs to be able to load the previous day values on load.
What is the best way of developing a web page for this? Is Jscript the best option? Can I access a local file with jScript?
Thanks in advance
Adrian
The easiest option for you is to use google web forms. These allow creation of forms that will submit data to a google spreadsheet. Which is essentially an uploaded version of your local spreadsheet and can be downloaded to excel.
In case if you want more control and programming, pure javascript cant play with files, you need server side too. Javascript is not necessary unless you want to make your app do some visually fancy stuff. Since you mentioned php as a tag of this question, it seems you are a bit familiar with php. The task you have mentioned can be done using php programming as below:
Read excel file using an excel plugin
Parse relevant data using a text matching function, may require regular expressions knowledge.
display the form by building up the html and putting in the variables using the data obtained above.
Write a method to save the data submitted by the form to the same excel file using the excel plugin.
As its not convenient to play around with excel files. A better option would be to generate csv file or use a database using a database class . csv files can be parsed easily using text.

Share excel data across real-time?

I have developed a VBA spreadsheet that runs locally and with obtain data from other sources continuously.
I want to find a way to extract / access the data inside this spreadsheet through php and then output some processed data using a browser and these data will update accordingly as the spreadsheet updates itself.
Anyone can show me how to achieve this? Both the spreadsheet and the php will run locally on a windows machine if that is easier...
Thanks very much for your help :)
I just developed an application that does this the idea is to use http requests on_change events in the spreadsheet.
vba code for request in excel
Function httpRequest(ByVal path As String) As String
Set HttpReq = CreateObject("MSXML2.ServerXMLHTTP")
HttpReq.Open "GET", path, False
HttpReq.Send
httpRequest = HttpReq.ResponseText
End Function
On your php side you have to develop the part where the data is mapped in the database. And of course the view of the data. As for realtime you have to go for something more elaborate like a table that holds the latest changes and check for such changes every now and then unless there is some mechanism to do so.
In excel there exist timers to acomplish polled checking for updates
for web you should to use ajax for seamless updates have a look at http://datatables.net/
You can use PHP Excel Reader to display the data quite easily from the spreadsheet - I think this is the simplest of the PHP Excel libraries that will do what you want and simply set the page to refresh on a regular basis.
Using this library is pretty much as simple as this:
<?php echo $data->dump(true,true); ?>
Once you have told it where the file is to display the output pretty much as would be expected to see in an Excel Workbook. (Here is a link to an example that they have up and running online)
This means you won't get any locking issues as the read is done rather quickly (assuming a reasonable file size and users won't really ever be more than a few minutes/seconds behind.
You want PHP to just generate HTML from Excel sheets? Excel supports HTML generation natively.
Try Save as Web Page to test the quality of HTML produced by Excel. If it's OK then all you'll have to do is write a small piece of VBA that will be generating HTML from your spreadsheets automatically.
Sort of CMS build in Excel.

Get PDF output from XML generated by a PHP file and translated with an XSLT

I've used a couple of days to think of a best practice to generate a PDF, which end users can customize the layout for themselves. The PDF output needs to be saved on the server or sent back to the PHP file so the PHP file can save it, and the PHP file needs to know that it went OK.
I thought the best way to do this was to use XML, XSLT and Apache Cocoon. But I'm not sure if this is possible or if it's a good idea since I can't find any information of people doing anything similar. It cannot be an uncommon problem.
The idea came when I read about Cocoon converting XML through XSLT to PDF:
http://cocoon.apache.org/2.1/howto/howto-html-pdf-publishing.html
and being able to take in variables:
http://old.nabble.com/how-to-access-post-parameters-from-sitemap-td31478752.html
This is what I had in mind:
A php file gets called by a user, the php file generates a source XML file with a specific name
The php file then makes a request to Cocoon (on the same web server) to apply the user defined XSLT on the XML file. A parameter will be needed here to know which XSLT to apply.
The request is handled by the PHP file and then saved as a PDF on the server, and can later be mailed away.
Will this work at all? Is there a better way to handle this?
The core problem is that the users need to be able to customize the layout on the PDFs themselves, and I need the server to save the PDF and to mail it later on. The users will use it for order confirmations, invoices, etc. And I wouldn't like to hard code the layout for each user.
I've had some good results in the past by setting up JasperReports Server and creating reports using iReport Designer. They're both available in F/OSS ("community") editions, though you can pay for support and value-adds if you need those things.
This was a good solution for us, since we could access it via the Java API for our Java system, and via SOAP for our PHP system. The GUI designer made tweaking reports very easy for non-technical business staff too.
I use webkithtml2pdf to generate my PDF:s. Just create a document with HTML and CSS for printing like you would usually do, the run it through the converter.
It works great for generating things like invoices. You can use SVG for logos and illustrations, and they will look great in print since they are vector based. Even rounded corners with dotted outlines works perfectly.
A minor gotcha is that the input html must have th htm or html file name suffix, so you can't use the default tempfile functions.

Modify PDF Forms from a PHP site

We currently use PDForm to grab a blank pdf file (no values, just form fields and text) and list the form fields. We then query our database for the values which match those field names and create a pdf file with the newly populated data which the user can download from our site. The thing is PDForm is about $5,000 per machine and we are migrating servers. We want an alternative which is actively supported and recommended by the community.
I know Zend is working on a PDF manipulation extension, but we need something quick. I have done testing with PDFtk but the last update for that project was in 2006 and it now seems dead. It would be fine as it is open source, however it seems to be causing errors with certain files that seem to be generated with PDFPenPro (our pdf form creator).
Another solution I thought up was why not just use iText and write a java wrapper which accepts command line input, so that PHP can call it with passthru() or exec(). There are other applications that will work should we completely rewrite our code but we do not want to do that.
What we need.
The ability for PHP to receive the PDF form field names.
PHP to then either create and FDF file (then merge it with the PDF) or send a string to a command line application which will populate the fields with values from our database.
The user can then download the newly created PDF file with the populated form fields.
Am I moving in the write direction by creating a java command line application that will use iText to parse and create the PDF files specified by PHP or does anyone know of any cost effective alternatives?
TCPDF seems to have the most robust feature set that I have seen so far.
Thanks, d2burke, for the tip on TCPDF. I'm not trying to do quite as much as the OP, but the software packages available to accomplish any kind of pdf generation are in the $2k to $3k range. TCPDF is php based, open source and the guy developing it is very supportive.
Always donate to these guys! Where in the world would web development be without it?
So since none of the above solutions would work since TCPDF doesn't work with forms the way we are wanting and since PDFlib converts the form fields to blocks we decided to create a command line wrapper for iText which will grab the form field names from the PDF and then populate them based on the database values.
I don't know if another product whose license costs range from $1k -> $3k could be considered "cost effective", but PDFlib work quite nicely. And if you don't need the PPS functionality, it does get cheaper.

Categories