Page 1 of 1

Passing information between frames in PHP

Posted: Fri Aug 12, 2005 11:20 am
by clangro
I currently have a 3-frame website I'm working on with a top, left and right frame.

The top frame is pure HTML for banners and logos, no big deal there.

The left frame is an HTML page that will have multiple drop-down boxes and a submit button that should pass $_POST variables to the right frame.

Left frame:

Code: Select all

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 4</title>
<base target="contents">
</head>

<body>

<form method="POST">
		<select name="equipment_type" id="equipment_type">
			<option value="junk">-------------------</option>
			<option value="%">All Equipment Types</option>
			<option value="E911">E911 Cables</option>
		</select>
		<select name="project" id="project">
			<option value="junk">-------------------</option>
			<option value="%">All Projects</option>
			<option value="Ericsson">Ericsson</option>
		</select>
		<INPUT TYPE="SUBMIT" VALUE="Submit">
<p>You should call up main.php here</p>
</body>

</html>
The right frame is the main.php frame to actually get data from a mySQL database. This is where the results will be displayed.

Code: Select all

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 4</title>
<base target="contents">
</head>

<body>
<p>This is the main.php file</p>
<?
			if ($_POST['equipment_type'] != 'junk')
			{
			     echo "<script type=\"text/javascript\">document.getElementById('equipment_type').value = '{$_POST['equipment_type']}'; </script>";
			}
			if ($_POST['project'] != 'junk')
			{
			     echo "<script type=\"text/javascript\">document.getElementById('project').value = '{$_POST['project']}'; </script>";
			}
			$username="acscable_client";
			$password="cat7";
			$database="acscable_tmobile";
			mysql_connect(localhost,$username,$password);
			@mysql_select_db($database) or die( "Unable to select database");
			$query="select * from tmobile where equipment_type like '".$_POST["equipment_type"]."' AND project like '".$_POST["project"]."'";
			$result=mysql_query($query);
			$num=mysql_numrows($result);
			mysql_close();
			$i=0;
			while ($i < $num) 
				{
					$region=mysql_result($result,$i,"region");
					$manu_part_num=mysql_result($result,$i,"manu_part_num");
					$acs_part_num=mysql_result($result,$i,"acs_part_num");
					$equipment_type=mysql_result($result,$i,"equipment_type");
					$project=mysql_result($result,$i,"project");
					$description=mysql_result($result,$i,"description");
					$picture=mysql_result($result,$i,"photo");
					echo "<br><br><img src=\"$picture\" align=\"left\"></img><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><br><br><br><br><br><hr><br>";
					$i++;
				}
		?>

</body>

</html>
Now, I need the data being submitted in the left frame to be passed to the right frame and displayed on the right frame. I also have some code in the right frame that would set the drop-down boxes to whatever value was selected after they were submitted. But the code from the right frame was created when all of this was on the same single page.

This can all be seen at:

http://acscable.com/test/index.html

I really have no idea what to do next. I know what to do logically thinking, but not how to actually do it. TIA

Posted: Fri Aug 12, 2005 11:58 am
by feyd
you can use a target in forms (even if you are using XHTML, just have to hack it into doing it.)