[Javascript] Creating a Popup without toolbars in Php/MySql using Javascript. - a solution

Jefferis Peterson jefferis at petersonsales.net
Wed Oct 2 11:25:09 CDT 2002


My Goal: To create an offset, popup window of a large, variable, picture of
jewelry for a site in development with a black background,  no toolbars and
a variable image.
[To view the page now working in progress:
http://www.yellow-diamonds.com/ViewALL.php  - and click on large view. ]


Problems:
In JavaScript you can create a popup, but passing a variable image from
MySql to the page turned out to be a problem. Since the record set contains
a repeating table of rows of items, the "large imageURL" variable of the
chosen row has to be passed to the popup page as a distinct variable. The
popup could display the image, but you couldn't set the background color.

Opening an existing page ["show_image.php"] with a black background with PHP
via  a link works, but it does not allow you to remove toolbar or set the
window size or placement. And, using onLoad behaviors like a simple
"self.resize" command in javascript causes variable image data to be lost to
the redrawn page.  



Environment: an MySql database [jodenonline] with an inventory and
description of jewelry. Two fields contains links to images in separate
folders [thumbnails and images]. The link information is relative not
absolute; i.e., thumbnails/image1.gif, images/image1.gif, etc.

The record set is created by a query called "viewall" for the entire catalog
sorted by item type [bracelets, rings, brooches, etc.]

Solution:
Opening an existing page {show_image.php} with a black background setting
the parameters for the page with an "onClick" behavior. Turning the variable
image $query data into a new variable called $img and passing that variable
to the page. 
Results: a popup with a set size, no toolbar, somewhat centered on the
monitor. 

Thanks to All for the help, and please check the pages for browser
consistency.  Relevant $query page and popup page code follows.

Jeff
~~~~~~~~~~~~~~~~~~~~~
Query Page: ViewALL.PHP

  <?php require_once('Connection.php'); ?>
<?php
$currentPage = $HTTP_SERVER_VARS["PHP_SELF"];

$maxRows_viewall = 10;
$pageNum_viewall = 0;
if (isset($HTTP_GET_VARS['pageNum_viewall'])) {
  $pageNum_viewall = $HTTP_GET_VARS['pageNum_viewall'];
}
$startRow_viewall = $pageNum_viewall * $maxRows_viewall;

mysql_select_db($database_jodenonline, $jodenonline);
$query_viewall = "SELECT * FROM `Catalog` WHERE `Catalog`.img_status = '1'
ORDER BY `Catalog`.item_type";
$query_limit_viewall = sprintf("%s LIMIT %d, %d", $query_viewall,
$startRow_viewall, $maxRows_viewall);
$viewall = mysql_query($query_limit_viewall, $jodenonline) or
die(mysql_error());
$row_viewall = mysql_fetch_assoc($viewall);

if (isset($HTTP_GET_VARS['totalRows_viewall'])) {
  $totalRows_viewall = $HTTP_GET_VARS['totalRows_viewall'];
} else {
  $all_viewall = mysql_query($query_viewall);
  $totalRows_viewall = mysql_num_rows($all_viewall);
}
$totalPages_viewall = ceil($totalRows_viewall/$maxRows_viewall)-1;

$queryString_viewall = "";
if (!empty($HTTP_SERVER_VARS['QUERY_STRING'])) {
  $params = explode("&", $HTTP_SERVER_VARS['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_viewall") == false &&
        stristr($param, "totalRows_viewall") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_viewall = "&" . implode("&", $newParams);
  }
}
$queryString_viewall = sprintf("&totalRows_viewall=%d%s",
$totalRows_viewall, $queryString_viewall);
?>
<html>
<head>
<title>Joden World Resouces Online Catalog www.Joden.com</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
</HEAD>
<BODY>

<a href="#"  onclick="MM_openBrWindow('<?php echo
"show_image.php?img={$row_viewall['pictures']}"; $img =
$row_viewall['pictures'];?>','','resizable=yes,width=550,height=400,toolbar=
0, left=200, top=150');return false">LargePicturesClick</a>
</BODY>
</HTML>
~~~~~~~~~~~~~~~
PopUpPage.php [show_image.php]

<HTML>
<HEAD> <TITLE>Large View of <?php echo $img; ?></TITLE> </HEAD>
<body   bgcolor="black" text="#FFFFFF" link="#FFFFCC" vlink="#FFFFCC"
alink="#FFFF99"  >
<DIV align="center">
  <IMG src="/<?php echo $img; ?>"><br>
   </DIV>
</BODY>
</HTML>
~~~~~~~~~~~~
Jefferis Peterson, Pres.
Web Design and Marketing
http://www.PetersonSales.net
Tel . 724-458-7169
ICQ 19112253

http://www.Slippery-Rock.com - 7,000 hits per year




More information about the Javascript mailing list