Home      Products & Services      Contact Us      Links

WebHatchers will design & develop your site for you.

Website Menu Heaven: menus, buttons, etc.

Send us your questions.

site search by freefind

SEO, Google, Privacy
   and Anonymity
Browser Insanity
Popups and Tooltips
Free Website Search
HTML Form Creator
Buttons and Menus
Image Uploading
Website Poll
IM and Texting
   or Not MySQL
Personal Status Boards
Content Management
Article Content
   Management Systems
Website Directory
   CMS Systems
Photo Gallery CMS
Forum CMS
Blog CMS
Customer Records
   Management CMS
Address Book CMS
Private Messaging CMS
Chat Room CMS
JavaScript Charts
   and Graphs

Free Personal Status Boards (PSB™)

Free Standard Free PSB

Free PSB Pro Version

Free Social PSB

Free Social PSB Plus (with Email)

Free Business PSB

Free Business PSB Plus (with Email)

PSB demo

Social PSB demo

Business PSB demo

So what's all this PSB stuff about?

Chart comparing business status boards

PSB hosting diagram

PSB Licence Agreement

Copyright © 2002 -
MCS Investments, Inc. sitemap

PSBs, social networking, social evolution, microcommunities, personal status boards
PSBs, social networking, business personal status boards
website design, ecommerce solutions
website menus, buttons, image rotators
Ez-Architect, home design software
the magic carpet and the cement wall, children's adventure book
the squirrel valley railroad, model railroad videos, model train dvds
the deep rock railroad, model railroad videos, model train dvds

Image enlarges on mouseover but uses PHP script in all image tags

Building a picture from scratch and displaying it on a web page but with no write permissions

This page is a tutorial on "Image enlarges on mouseover but uses PHP script in all image tags". Our overall method is to use MySQL and PHP. All over the Internet, the discussions of using PHP to upload image files to the server seem to have a common thread. "You have to have write permissions." This is sort of true and sort of not true. All of our experiments were done with CHMOD 750 on our public_html folder and CHMOD 755 on our test subfolder. Server warnings were all we got from trying to CHMOD from either a script or from our FTP program. So we had to live without write permissions (sigh . . . ). But we still got the job done 3 different ways!

This page uses the image-on-web-page.php, make-pic.php, and show-pic.php scripts as its framework but special DHTML tricks for displaying images on a web page.

For those of you with write permissions, How to Get Around Needing Write Permissions When Saving Images on Server contains listings of the 2 files that will let you upload and manipulate images.

The following method is a perfect workaround for needing write permissions that you simply do not have and cannot get. To be clear, you do NOT need write permissions to store pictures in MySQL and use our scripts to display them. You DO need write permissions to use PHP file uploading methods if you aim to stick images into online folders. Many experts say this creates an unacceptable vulnerability and simply too much risk. The alternatives to this CHMOD 777 free-for-all where strangers are permitted to stick image files on your server are:

The rest of this page assumes you wish to use our store-image-data-in-db scripts, and that you like the idea of images enlarging when your cursor is on them. We made a photo gallery app which you can demo here: photo gallery demo that uses this idea.

As trivial an HTML page as the following can display your MySQL-stored image in the browser (a width parameter of 100 will turn a large image into a thumbnail, while leaving out parameters will let the image display at its original size):

<img src="image-show.php?p1=4" alt="image">

But you want the cool enlargement dynamic, so the "Image enlarges on mouseover but uses PHP script in all image tags" script is below, and it is composed of 1 part. Of course, to actually use the script on a web page, you need to use a URL query string so the receiving script will know which image to get—unless there is only one, of course.

So let us check out the script for enlarging: First, after a bit of CSS we run a browser sniffer. Modern Firefox browsers probably don't require this, but Netscape and probably other Netscape-like browsers still do. The body tag runs the onLoad event which runs the JavaScript startmouse() function. What this aspect of the script is trying to do is read the mouse cursor coordinates. The reason onMouseOver would not work is that even though it would be fine for the enlarged image displaying feature, it would stink at knowing when to let the larger image disappear. See Browser Bug? to see where they went wrong. How seriously weak is it that the browser cannot tell when it is no longer over the smaller image if the bigger image is "in the way"?! But a cursor reader script has NO such problem and is much more responsive and effective and versatile. So that is what we used.

Note that browsers capture the onMouseMove event in more than one way. Netscape and older Firefoxes take a priming of the pumps to get started, but IE needs no coaxing. Once we get to the getCoords() function, the browsers again use different methods to get the cursor position. Once the positions of these coordinates are known, they are compared with the screen position of the image. This same coordinate reading script is in our photo-gallery.html script, but you can see how it needs tweaking to deal with multiple photos on a page. On the script below, there is but one image to enlarge.

Once the script determines the cursor is over the photo, it runs the move(450) function, and once the cursor is outside those coordinates, it runs the move(-750) function, with move()—as you can see—doing nothing but dynamically altering the left CSS property. So the photo div that is the enlarged version is simply moving offscreen and onscreen by shifting right or left. Just to make our onMouseOver event point, we used it to make the enlargement appear, but strenuously avoided using the onMouseOut event for disappearing the enlargement, since it would have failed embarrassingly. We could just as easily have avoided onMouseOver and let cursor reading run both image enlargement and image shrinking. Call us lazy. Note that JavaScript in particular and browsers in general do not mind if one stores offscreen divs for display when the time is ripe.

In this particular script, we use show-pic.php as the source attribute in an image tag. SRC is normally where a jpg, png, bmp, or gif goes, of course. But HTML doesn't mind if we use a PHP script instead. In practice there would be a query string that would inform the PHP script which image we want, but show-pic.php was not built for that, although the scripts in Read image immediately into mysql to solve no write permissions problem are built for that.

The script is called: image-on-a-web-page.php

<style type="text/css">
BODY {background-color:#88f;}
var x = 0;
var y = 0;
var Netscape=(navigator.appName.indexOf("Netscape") != -1);

function startmouse() {if(Netscape) {document.captureEvents(Event.MOUSEMOVE);} document.onmousemove=getCoords;}

function getCoords(e){
if (!e) var e = window.event;
if (e.pageX){x = e.pageX;y = e.pageY;}
else if (e.clientX){
x = e.clientX + document.body.scrollLeft;
y = e.clientY + document.body.scrollTop;}

var k = 0;
var yy = 80;
var xx = 450;
var ww = 100;
var hh = 138;

function move(l){e=document.getElementById('o');e.style.left=l;}



<body onload="startmouse()">

<table style="position:absolute;top:80px;left:450px" align="left" border="1" width="100px" height="138px" cellspacing=0 cellpadding=0>
<td width="100" height="138"><img src="show-pic.php" alt="Hillary" width="100px" height="138px" BORDER=0 onMouseOver="javascript:if(k==0){move(450);k=1;}return true"></td>

<div id="o" style="position:absolute; left:-750px; top:80px; width:350px; height:484px; border:3px groove #888;"><IMG SRC="show-pic.php" WIDTH=350 HEIGHT=484 BORDER=0></div>