Windows

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alanmahony
Forum Newbie
Posts: 4
Joined: Tue Oct 28, 2003 8:30 am

Windows

Post by alanmahony »

Hey I was wondering if anyone could help me with this I have a php script that takes in values from th user and adds them to a session and when submit is click I want the script to open a new window at a specifed size and have this window call a php script i've tried this with javascript with window.open('barchart.php','myWindow','height=200,width=200') but it won't open the new window but if i put window .close() it will close the window so it is recgonising javascript.

Thanks
TheBentinel.com
Forum Contributor
Posts: 282
Joined: Wed Mar 10, 2004 1:52 pm
Location: Columbus, Ohio

Post by TheBentinel.com »

Can you post the code you're using to open the window that's not working? I mean the whole function or script, so we can see it in context. And is it giving you an error or message, or just not doing anything at all?
alanmahony
Forum Newbie
Posts: 4
Joined: Tue Oct 28, 2003 8:30 am

Post by alanmahony »

Ok the first block of code deals with getting the details from the user:

<?php
error_reporting(0);
session_start();
echo "<script src=\"popup.js\" type=\"text/javascript\">
</script>";
$crime = $_SESSION['crime'];
$years = $_SESSION['years'];

if(isset($_GET['graph']))
{

$crime = $_POST['crime'];
$years = $_POST['years'];

$_SESSION['crime'] = $crime;
$_SESSION['years'] = $years;

echo " <script language=\"javascript\">
my_win();
</script>
";
}

else {
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
\"http://www.w3.org/TR/html4/loose.dtd\">
<html>
<head>
<script src=\"popup.js\" type=\"text/javascript\">
</script>
<title>Untitled Document</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
<style type=\"text/css\">
<!--
body {
background-color: #d4daff;
}
.style1 {
font-family: Georgia, \"Times New Roman\", Times, serif;
font-weight: bold;
}
.style2 {font-size: 12px}
-->
</style></head>

<body><table width=\"886\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td width=\"26\"> </td>
<td width=\"860\"><img src=\"top2.jpg\" width=\"807\" height=\"155\" border=\"0\"></td>
</tr>
</table>
<table width=\"885\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td width=\"121\"><p>
<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shoc ... on=5,0,0,0\" width=\"100\" height=\"22\">
<param name=\"BGCOLOR\" value=\"\">
<param name=\"movie\" value=\"home.swf\">
<param name=\"quality\" value=\"high\">
<embed src=\"home.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/shockwave/dow ... kwaveFlash\" type=\"application/x-shockwave-flash\" width=\"100\" height=\"22\" ></embed>
</object>
</p>
<p>
<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shoc ... on=5,0,0,0\" width=\"100\" height=\"22\">
<param name=\"movie\" value=\"comments.swf\">
<param name=\"quality\" value=\"high\">
<embed src=\"comments.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/shockwave/dow ... kwaveFlash\" type=\"application/x-shockwave-flash\" width=\"100\" height=\"22\" ></embed>
</object>
</p>
<p>
<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shoc ... on=5,0,0,0\" width=\"100\" height=\"22\">
<param name=\"BGCOLOR\" value=\"\">
<param name=\"movie\" value=\"contacts.swf\">
<param name=\"quality\" value=\"high\">
<embed src=\"contacts.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/shockwave/dow ... kwaveFlash\" type=\"application/x-shockwave-flash\" width=\"100\" height=\"22\" ></embed>
</object>
</p>
<p>
<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shoc ... on=5,0,0,0\" width=\"100\" height=\"22\">
<param name=\"movie\" value=\"alert.swf\">
<param name=\"quality\" value=\"high\">
<embed src=\"alert.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/shockwave/dow ... kwaveFlash\" type=\"application/x-shockwave-flash\" width=\"100\" height=\"22\" ></embed>
</object>
</p>
<p>
<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shoc ... on=5,0,0,0\" width=\"100\" height=\"22\">
<param name=\"movie\" value=\"check.swf\">
<param name=\"quality\" value=\"high\">
<embed src=\"check.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/shockwave/dow ... kwaveFlash\" type=\"application/x-shockwave-flash\" width=\"100\" height=\"22\" ></embed>
</object>
</p>
<p>
<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shoc ... on=5,0,0,0\" width=\"100\" height=\"22\">
<param name=\"movie\" value=\"rates.swf\">
<param name=\"quality\" value=\"high\">
<embed src=\"rates.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/shockwave/dow ... kwaveFlash\" type=\"application/x-shockwave-flash\" width=\"100\" height=\"22\" ></embed>
</object>
</p>
<p>
<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shoc ... on=5,0,0,0\" width=\"100\" height=\"22\">
<param name=\"movie\" value=\"garda.swf\">
<param name=\"quality\" value=\"high\">
<embed src=\"garda.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/shockwave/dow ... kwaveFlash\" type=\"application/x-shockwave-flash\" width=\"100\" height=\"22\" ></embed>
</object>
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp; </p></td>
<td width=\"27\"><img src=\"rail2.jpg\" border=\"0\" width=\"27\" height=\"385\"></td>
<td width=\"737\"><div align=\"center\" class=\"style1\">
<h2>Check Your Areas Crime Rate for the Past Year </h2>
<p>&nbsp;</p>
<form action=\"graph.php?graph=Yes\" method=\"post\" name=\"graph\" id=\"graph\">
<table width=\"465\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td width=\"299\"><p class=\"style2\"><label>Please Enter The Crime to Graph </label></p></td>
<td width=\"166\"><input name=\"crime\" type=\"text\" id=\"crime\"></td>
</tr>
<tr>
<td><p class=\"style2\"><label>Please Enter The Number of Years to Graph </label></p></td>
<td><input name=\"years\" type=\"text\" id=\"years\"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><p>&nbsp;</p>
</td>
</tr>
</table>

<p>
<input type=\"submit\" name=\"Submit\" value=\"Submit\">
<input name=\"Reset\" type=\"reset\" id=\"Reset\" value=\"Reset\">
</p>
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div></td>
</tr>
</table>
</body>
</html>";
}

?>

the next block is java script

function my_win()
{
var popurl="barchart.php"

winpops = window.open(popurl,"","height=200,width=400,toolbar=no,scrollbars=no,status=yes,resize=no")

}

and finally the code i want outputted to a new window

<?PHP

session_start();

$crime = $_SESSION['crime'];
$years = $_SESSION['years'];

/* START OF BAR COORDINATES */
$x1 = 35;
$y1 = 150;

/* LABELS */
$labelX = "Crime Rate for the Past $years Years From 2004";
$labelY = "$crime Rate";

/* SET DATE IN GRAPHS */
$dateNow = date("H:i:s D d M Y");
$int = date("Y") - $years;
$control = date("$int-m-d");

// SET THE MAIN GRAPH VARIABLE
$graph = ImageCreate(300,200); // INTEGERS REPRESENT, IN ORDER, WIDTH & HEIGHT

// SET COLOR VARIABLES
$black = ImageColorAllocate($graph, 0, 0, 0);
$white = ImageColorAllocate($graph, 255, 255, 255);
$cuscolor = ImageColorAllocate($graph, 179, 214, 210);


// CREATE THE BACKGROUND FOR THE GRAPH line24
ImageFill($graph, 0, 0, $white);

/* SET UP GRAPH BASICS */

// CREATE THE SIDE BARS FOR THE GRAPH
ImageLine($graph, 25, 150, 200, 150, $black); // HORIZONTAL, X AXIS
ImageLine($graph, 25, 0, 25, 150, $black); // VERTICLE, Y AXIS

/* CREATE THE LABELS FOR THE X AND Y AXIS */
ImageString($graph, 2, 50, 150, $labelX, $black);
ImageStringUp($graph, 4, 10, 150, $labelY, $black);

// **CONNECT TO THE DATABASE**
$connect = mysql_connect('localhost', 'root', 'marese');
mysql_select_db('Stats',$connect);

$TotalTime = 0;
$NumBoards = 0;
$AvgInspTime = 0;

$Result = mysql_query("SELECT Rate FROM homicide Where Type = '$crime' And Date > '$control' Order By Date ASC");
while ($row = mysql_fetch_array($Result)) {
$x2 = $x1 + 20;
$y2 = $row['Rate'];
$x3 = $x1 + 3;
$y3 = $y1 - 10;
$y4 = $y1 - $y2;
ImageFilledRectangle($graph, $x1, $y4, $x2, $y1, $cuscolor);
ImageStringUp($graph, 4, $x3, $y3, $y2." Crimes", $black);
$x1 = $x2 + 10;
}

/* SEND THE HEADER TO THE SERVER */
Header("Content-type: image/gif");

/* OUT PUT THE RESULTING GRAPH TO THE BROWSER */
ImageJPEG($graph);

/* MEMORY CLEAN UP */
ImageDestroy($graph);

?>

Cheers
Post Reply