RPV Reports / Rpv & Php. Rpv Reports on internet
 
Search in RpvSoftware.com
Go!

What Rpv is

Rpv Reports 6

Downloads

Support

Buy now!

Contact us

 
Home >     [Ver en Espaņol]

Rpv Reports & PHP

Rpv executes PHP programs on a remote server and collect the data that the program generates.
Basically, it can do the same that a web browser does: executes a program and shows its results.

How Rpv does this

Rpv receives the results sent by the PHP program and understands the format. For example, the PHP program could be sending an RPX format, or a pure RPV report (without templates... old format).
When Rpv understands the format it manages the report according it and loads the templates and other third needed files.
All the files: basically templates and images can be on the remote server (the same server or another remote server), or can be on the local disk or on a network. What is important is to provide Rpv a proper path to access the files.


RPX report with PHP

Rpx is the most recommended for all purposes and for PHP too.

Generating the Rpx.

For this example, we have a countries table that you can recreate with the following text file (download)
What the program does is to read the table "countries" and show all the records on the report.
Basically, what is needed is to generate the same RPX that you would be generating on your disk. Click here to see how the generated RPX looks like. (internet browser)

<?
  $link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password') or die('Could not connect: ' . mysql_error());
  echo 'Connected successfully';
  mysql_select_db('my_database') or die('Could not select the database');

  echo 'TEMPLATE=http://www.rpvsoftware.com/webreports/countries.rpv<br>';
  $querysentence = "SELECT * FROM countries";
  $result = mysql_query($querysentence);
  while($row = mysql_fetch_array($result))
    {
      echo '|detail|' . $row['idCountry'] . '|' . $row['countryCode'] . '|' . $row['countryName'] . '|' . $row['currencyCode'] .'|' . $row['population'] . '|' . $row['fipsCode'] . '|' . $row['isoNumeric'] . '|' . $row['north'] . '|' . $row['south'] . '|' . $row['east'] . '|' . $row['west'] . '|' . $row['capital'] . '|' . $row['continentName'] . '|' . $row['continent'] . '|' . $row['areaInSqKm'] . '|' . $row['languages'] . '|' . $row['isoAlpha3'] . '|' . $row['geonameId'] . '|
';
    }
?>



This program has been prepared to run on your Rpv Viewer. However, you can run it on your browser to see how it looks. Click here to see it on browser

Run the program / See the report

See this program on Rpv Reports Viewer (6.0 or higher)

What the link says? <a href=viewrpvreport:http://www.rpvsoftware.com/webreports/countriesreport.php>Click here to see the report</a>

The example is great. Now, how do I make it work?

Great question. Here, we explain how to do it.

First of all, you must have access to a PHP server with database.
After that, create a database or select one. In this case, we have a database named countriesdb.
Here you have the command to create the table on your database: Table countries
Select all the text and paste this on your SQL panel and the table with all the records will be created.


When you have the table and records created, is the time to create the PHP file.

Coding the PHP program

The PHP program will create the delimited file that Rpv needs to read. Our suggestion is always to prepare the Rpx file (the delimited file) leaving the template as last step.

Here we show again how the PHP program is created. Copy, paste and modify the data to connect to your database.
<?
  $link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password') or die('Could not connect: ' . mysql_error());
  echo 'Connected successfully';
  mysql_select_db('my_database') or die('Could not select the database');

  echo 'TEMPLATE=http://www.rpvsoftware.com/webreports/countries.rpv<br>';
  $querysentence = "SELECT * FROM countries";
  $result = mysql_query($querysentence);
  while($row = mysql_fetch_array($result))
    {
      echo '|detail|' . $row['idCountry'] . '|' . $row['countryCode'] . '|' . $row['countryName'] . '|' . $row['currencyCode'] .'|' . $row['population'] . '|' . $row['fipsCode'] . '|' . $row['isoNumeric'] . '|' . $row['north'] . '|' . $row['south'] . '|' . $row['east'] . '|' . $row['west'] . '|' . $row['capital'] . '|' . $row['continentName'] . '|' . $row['continent'] . '|' . $row['areaInSqKm'] . '|' . $row['languages'] . '|' . $row['isoAlpha3'] . '|' . $row['geonameId'] . '|
';
    }
?>

When this program runs, it will generate a list of delimited fields. That will be the RPX that Rpv Reports will format.
See it with a browser and save it to an RPX file.

Select all the text on the browser and copy it to clipboard.


Open a notepad and paste the information. After that save the info on your hard disk with any name and RPX extension.


Creating the template with Rpv Visual Editor
Now that we have the RPX on our disk we will generate the template with the Visual Editor. Just create a new document with Rpv Visual Editor and set 'Sample Rpx/Rpd file' pointing it to the file recently saved on disk.
That will tell the Rpv Visual Editor how to create the template.


After this, click on Edit/New Subsection. You will see a window like the following:
The RPX file that has been declared before tells Rpv Visual Editor how to create the subsection. Please note that it shows the fields with the data.

By default, fields are @field01, @field02, @field03, etc, but you can change their names (and possibly should) to identify each field properly.
It is not needed that the names of the fields are the exactly the ones that the PHP program has. In fact, it is always recommended to short the names to better understand the templates. The field names are not case sensitive so @FIELD01 is the same as @field01.

Click Ok to create the subsection. (The names of the fields can be changed later if needed).


When you click Ok, an empty subsection is created. You can see all the names of the fields on the declaration. Double clicking on the declaration opens the subsection properties.

Now, is time to add the fields on the subsection. To do that just place the mouse exactly where you want to place the @field and click ctrl-D. Rpv Visual Editor understands that the field to be inserted is the next one. It is possible to show multiple times the same field on the same subsection.

It is important to understand what a subsection is: here you see the "detail" subsection that contains several "@fields". Every time that "detail" appears on the Rpx file the subsection is repeated.

After this, just finish the template. Add labels, images, change colors and styles to make the report more attractive.

When it is done just save it. Next step will be to upload it to the web server.
For the example, the template is uploaded on http://www.rpvsoftware.com/webreports/countries.rpv.
By the way... the example exists and you can open it from your Rpv Reports Viewer. Try by pasting the address on the viewer.

Tip: if you want to work with web reports, we suggest to delete the cache every time Rpv exits. This is not indicated to end users because Rpv has to download everything every time it has to manage a report. For the developer is indicated because you need Rpv always reads the the last version of the files that are uploaded. Just go to the advanced settings and type

DELETECACHE=Y

You can access the advanced settings executing the RPVCONFIG.EXE utility or from the Rpv Viewer.

Do you have questions? Please contact us with your enquires!

Didn't you find what you were looking for?

About
What Rpv is
Rpv Reports 2024

Products
Rpv Reports 2024
Personalized edition

More...
Downloads
Support
Rpv Visual Editor online help
Examples
/temp section
Videos




Copyright (c) 2001-2024 - Rpv Software. All rights reserved.