This is a sample of the code we used in Molecular Simulation Database in order to visualize molecular simulation data store in a PostgreSQL database given some parameters entered by a user on a web form.
demo_usage.php shows a new visualization object being made through polymorphism. The class of the object could be twodpng, twodgif, threedpng or threedgif. You can set the title, add data points, and make other changes to these objects. Calling ->export() on the PHP object creates a gnuplot script on disk and runs it. gnuplot outputs an image to disk, which can then be loaded into a webpage.
Written by Maxwell Pietsch as part of a project with Dr. Tu, available online at Molecular Simulation Database.