Passing a parameter across frames

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
mutuah
Forum Newbie
Posts: 3
Joined: Tue Feb 26, 2008 7:54 am

Passing a parameter across frames

Post by mutuah »

Hi all.
Am trying to pass a parameter from one frame to another. What I have done, I have created an hyperlink from the left frame and in the link, am passing a variable thru url re-writing. But when i check the right frame, the variable is not seen. How can i solve this problem?

This is the code for leftframe:
<?php
include ("dbconnect.php");
$sql = 'SELECT committee_display FROM committee'
. ' ORDER BY committee_display';
$result = @mysql_Query($sql);
if (!$result) {
exit ( '<p> Error performing query: '. mysql_error() . '</p>');
}
?>
<br/>
<strong>Browse by Sector</strong><br>
<?php
//echo ('<b>'.'Records found: '.mysql_num_rows($result).'</b>');

while ($row = mysql_fetch_array($result)){
?>
<table width="238" border="0">
<tr>
<td width="6" height="10">&nbsp;</td>
<td width="222"><a href="rightFrame.php?displayName=<?php echo $row['committee_display']; ?>"
target="rightFrame"> <strong><?php echo $row['committee_display']; ?></strong></a></td>
</tr>
</table>
<?php
}
?>

The code for the right frame is:
<?php
include ("dbconnect.php");
$displayName = $_GET['$displayName'];
echo ('Variable passed: '.$displayName.'<br>');
//$displayName = 'Agriculture';
$sql = 'SELECT committee_name, decision_id, decision_name, decision_date '
. ' FROM decision, committee'
. ' WHERE decision.committee_id = committee.committee_id'
. ' AND committee_display = '. '"'. $displayName.'"'
. ' ORDER BY decision_id';
$result = @mysql_Query($sql);
if (!$result) {
exit ( '<p> Error performing query: '. mysql_error() . '</p>');
}
echo ('<b>'.'Records found: '.mysql_num_rows($result).'</b>');
?>

<table width="414" border="1" align="center">
<tr>
<td width="62"><strong>Sector:</strong></td>
<td width="342"><strong><?php echo $displayName; ?> </strong></td>
</tr>
</table>
<em><strong>Click on the hyperlink to view indicators associated with a decision</strong></em> <br>
<table width="588" border="1" align="center">
<tr>
<th width="113"><strong>Decision ID</strong></th>
<th width="319"><strong>Decision</strong></th>
<th width="134"><strong>Decision Date</strong></th>
</tr>
<?php
while ($row = mysql_fetch_array($result)){
?>
<tr>
<td><?php echo $row['decision_id']; ?></td>
<td><?php echo $row['decision_name']; ?> </td>
<td><?php echo $row['decision_date']; ?> </td>
</tr>
<?php
}
?>
robble
Forum Newbie
Posts: 11
Joined: Fri Aug 24, 2007 6:34 am

Re: Passing a parameter across frames

Post by robble »

Hi Mutuah

Just edited my whole post out after noticing one thing! VERY SIMPLE on your rightFrame.php

Code: Select all

$displayName = $_GET['$displayName'];
should be

Code: Select all

$displayName = $_GET['displayName'];
You left the '$' on the front of displayName on your $_GET :)
Post Reply