Display php and mysql database content via the
overlibmws DHTML Popup Library
maintained by Foteos Macrides at Macrides Web Services
Discuss these examples, seek help, and offer suggestions for
server-side script support via the
overlibmws Support Group.

This example uses overlib popups to display information obtained by php from a mysql database.  The markup for that document is shown below, with the php and database access coding in the salmon-colored area.  The overall markup is intended to serve as a guide for using overlib DHTML tooltip or sticky popups in conjunction with any server-side scripting and database software.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>overLIB - Virginia Good Bob Camping Clubs</title>

<script type="text/javascript" src="overlibmws.js"></script>

<script type='text/javascript'>
OLpageDefaults(WRAP, BASE, 2, CGCLASS,'olcg', FGCLASS,'olfg', CAPTION, 'Service Area',

<style type='text/css'>
.olcg {background-color:#333399; text-align:center;}
.olfg {background-color:#ffffcc; text-align:center;}
.olcap {font-family:Verdana,Arial,Helvetica;font-size:11px;color:#ffffff;font-weight:bold;}
.oltxt {font-family:Verdana,Arial,Helvetica;font-size:13px;color:#000000;}

body {color:#000000; background-color:#ddeeff;}

a {color:#338855;font-weight:bold;}
a:hover {color:#FF00FF;}

.text14 {font-family:Verdana,Arial,sans-serif; font-size:14px;}
.text12 {font-family:Verdana,Arial,sans-serif; font-size:12px;}

<body text="#000000" bgcolor="#ddeeff">

<table width="300" border="0" align="center" cellspacing="2" cellpadding="5">
<tr><td class="text14">
<b>Virginia Good Sam Clubs
<span class="text12">Mouseover each link for area served</span></b>
$mysqldb = mysql_pconnect($dbhost,$dbuser,$dbpassword);
if (!$mysqldb) {
echo "<tr><td class='text14'>Can't connect to database!</td></tr></table>";
mysql_select_db($dbname, $mysqldb) or die("Could not select the $dbname
database, while attempting to access table:'chapters'");
$result = mysql_query("select chapterName, service_area from chapters", $mysqldb);
if (!$result) {
echo "<tr><td class='text14'>Could not run the query.</td></tr></table>";
while (list($chapterName, $SA) = mysql_fetch_row( $result)) {
echo '<tr><td class="text12"><a href="javascript:;" onMouseOver="return overlib(\''.$SA.'\');"


The include_once() call should be modified appropriately for your server or be omitted.

Notice that the overlib calls have been kept short by using the OLpageDefaults() configuration function from the overlibmws core module.  Thus, all that needs to be included in the overlib calls by the server-side script is the overlib lead argument with text from the database.  The CAPTION has been pre-defined.  In other cases, it might also use content from the database, or be a variable related to the main text retrieved from the database.

Also notice that in this example the variable $SA used for the overlib lead argument is being enclosed by single quotes, and they must be backslash escaped because the whole echo statement is being delimited by single quotes.  If $SA contained any single-quotes (e.g., apostrophes in possessive nouns), double-quotes, or HTML markup, then it should be processed through the php addslashes(), htmlspecialchars(), htmlentities() or rawurlencode() functions, depending on what it contained.  See the paragraph about the overlib call's lead argument in the Command Reference.

See additional examples of quoting php strings for overlibmws.

This document uses overlibmws and its commands

Copyright Foteos Macrides
  All rights reserved.