FSI Viewer with PHP and MySQL™

With its possibility to be altered via HTTP queries, FSI Viewer can be dynamically implemented into existing websites or Content Management Systems (CMS).
In this tutorial we will demonstrate how FSI Viewer can be controlled using the popular scripting language PHP and a MySQL database. For this tutorial you should bring:

  • some PHP and SQL knowledge
  • a webserver running an imaging server, MySQL and PHP

In the following sample, FSI Viewer is updated by HTTP Queries via a little PHP Script, querying a MySQL Table.
You can download and import the following SQL-Dump to your own MySQL Database, eg. via phpMyAdmin:

As you can see, the database table holds the image path and name, the dimensions, tile and 3D information for 2 sample pictures. For demonstration purposes we stick to these parameters, otherwise the demonstration scripts would become too complex. Now we also need a little script to connect to the database:

The following ‘index.php’ displays both sample pictures, both being links to the same page, handing over their ID so the script can find and read the image properties when being clicked on:



As you can see above, the script reads the Picture ID, that is passed to the script via HTTP GET, when clicking a picture (<a href=”index.php?picture_id=1“>Picture 1</a> ). The script makes use of the fetch_fpx_image() function (posted below) to get all the info from the database, and changes the <OBJECT>…</OBJECT> code to be generated and also displays the results in human readable form. With a little PHP-knowledge, the script can be enhanced to suit any needs, like react on different image sizes and 2D/3D images.

Now lets take a look how the information is being read from the MySQL database:


The function generates a named array in the form of $query_collection[‘Mode3D’] = ‘Yes’ that is URL encoded,
as all parameters passed to FSI Viewer in such a way must be URL Encoded.
That array is then turned into one large string, dividing each parameter retrieved by the &-symbol, returning a full valid Query that can be used to configure FSI Viewer.