PHP Scripts

Javascript effects within PHP
(popup)

An easy and clean process:
1. Write php variables for javascript
2. String them together

In this example, results are called from a database, and clicking an icon pops up a window advising that the link is non-functional. The window page is 'nix.htm' and sized 450 X 392 pixels.

<html>
<head>
<?php
$result = mysql_query("SELECT * FROM table",$db);
$num_rows = mysql_num_rows($result);
if ($myrow = mysql_fetch_array($result)) {

$range='<img src=http://website/images/icons/small/';
$java='onMouseDown=';
$nixem='javascript:window.open';
$o1='http://website/nix.htm';
$o2='nix';
$o3='width=450,height=392';
$c='"';
$nix=$java.$c.$nixem;
$q='(';
$r=')';
echo "<table border=0>\n";
echo "<tr><td></td><td><td></td></td></tr>\n";
do {
printf("<tr><td>%s</td><td>%s</td><td>$range%s.gif $nix $q'$o1', '$o2', '$o3'$r$c>
</tr>\n", $myrow["field1"], $myrow["field2"], $myrow["field3"]);
} while ($myrow = mysql_fetch_array($result));
echo "</table>\n";
} else {
echo "no records at present";
}

mysql_free_result($result);
mysql_close($db);

?>

</BODY>
</html>

Demo ( bottom 1/2 of page)

Back