Forum Moderators: coopster

Message Too Old, No Replies

Array variable scope in a page

scope of array in a page

         

kyler

4:27 pm on Jan 26, 2005 (gmt 0)

10+ Year Member



I have two processes I am trying to acomplish. and am having trouble getting the second part of my process to work I am guessing due to scope or misuse of code.

in this code I am tring to re-use an array pulled from a sql statment in a statment exicuted when the person selects an Anchor
the areas are defined with AS follows

// part1 sql pull array

// part1 sql pull array used first time$Result1

Part 2 Reusing the Array from part 1 here again $Result1

<?php
session_start();
@extract($_POST);

if (isset($_POST['action']) && $_POST['action'] == 'supporter_modify') {
require_once("../function.php");
// define each value from the post
$Category = stripslashes($Category);
$Supporter = stripslashes($NON);
If ($Supporter == 'on'){
$Supporter = "n";
} else {
$Supporter = "y";
}

$SQLstatment = "SELECT * FROM supporters WHERE Category='" .$Category. "' AND supporter='" .$Supporter. "' ORDER BY supportername ASC;";
Get_db_RS ($SQLstatment);

// part1 sql pull array

$Result1 = $_SESSION['result'];

// define table color alernates
$colour_odd = "#F2F3F3";
$colour_even = "#E5EFF6";
$row_count = 0; //To keep track of row number

$Mod_people = "
<div class=\"rightnavheaderblue\"><h3>PRESCRIPTION DRUG RE-IMPORTATION NON-SUPPORTERS</h3></div>
<div class=\"maincontent\">Click on the names below to modify their entries</div><br /><br />
<table>

";

// loop through the records and concatenate to NonList string

// part1 sql pull array used first time$Result1

while($row = mysql_fetch_array( $Result1 )) {
// Decide which colours to alternate for the rows
// If Remainder of $row_count divided by 2 == 0.
$row_color = (($row_count % 2) == 0)? $colour_even : $colour_odd;
// Print out the contents of each row into a table
$Mod_people .= "<tr><td bgcolor=\"" . $row_color . "\">
<a href=\"political_modify.php?personId=".$row['SupportId']."\" class=\"maincontent\" border=\"0\">".$row['SupporterName'].":</a><br>
</td></tr>";
$row_count++;
}

$Mod_people .= "
</table>
";
echo $Mod_people; // This contains a list of a people selected from the pulldown with a passed value of the persond Id tag
die;
}
if (!empty($_GET['personId'])){
//echo "pass"; // this is for first step testing
echo $_GET['personId'];

// Part 2 Reusing the Array from part 1 here again $Result1

while($row = global mysql_fetch_array( $Result1 )) {
echo $row['SupporterName'];
}

die;
// Next step is to use the passed variable in the url to present the person and info
}

?>

[edited by: jatar_k at 6:48 pm (utc) on Jan. 26, 2005]
[edit reason] fixed bb code [/edit]

coopster

3:01 am on Jan 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Have you actually executed the query with mysql_query() [php.net]?

kyler

1:41 pm on Jan 31, 2005 (gmt 0)

10+ Year Member



I have changed the code around it's longer but works
This is the company rule.....Get er done NOW..

I have the sql at the top of the code calling a function and everything is working