[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.8

Add $_POST array data to $_SESSION array

Asked by vmurray in PHP Scripting Language, PHP for Windows, Hypertext Markup Language (HTML)

Tags: PHP $_POST $_SESSION array

I'm creating a multipart form that uses a multiselect textarea and trying to pass the result of that [array] into a $_SESSION array.  Having extreme difficulty...

I created "navigation" links in order to jump back and forth between pages (and pull from session data).  Everything works except for the arrays.  I think the problem may be how I'm passing POST array into the SESSION array, but not sure.

ie: This line...
$_SESSION['ProjectSelect'] = $_POST['ProjectSelectArray'];

I'll post each page below.  When you submit the page 1 with the multiselect textarea array/form, it will POST and display fine on page 2 using the SESSION array... however when you click on the link to go back to page 1 (and retrieve SESSION array to automatically select textarea values) it always "removes" the first ID value in the SESSION array.

I really have all this in one page (over 1000 lines of multiform, multi"page" code), but after spending a full day on trying to debug... I isolated this to be the problem and replicated it (with much less complicated logic into 2 separate pages)...

Actually... I'm having a hard time copying all this code into this code preview panel due to formatting, so I'll just post the problem area and see if someone has an obvious answer that I'm missing.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
Page1.php---------->
print ("<form style=margin:0 id=ProjectForm name=ProjectForm method=post action=page2.php>
<tr><td><select name=ProjectSelectArray[] size=15 multiple=multiple id=ProjectSelectArray[]>");
					
//Get All Projects
$tsql = "SELECT * FROM Projects WHERE Active=1 ORDER BY ProjectName";
$stmt = sqlsrv_query($conn1, $tsql);
$str = "";
					
while($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC))
{
	$a = count($_SESSION['ProjectSelect']);
	for ($i=0; $i<$a; $i++) {
		$ProjectID = $_SESSION['ProjectSelect'][$i];
		if ($ProjectID == $row[ProjectID]) {
			$str = "selected";
		}
	}
	print ("<option value=$row[ProjectID] $str>$row[ProjectID]: $row[ProjectName] $str</option>\n");
	$str = "";
}
print ("</select></td></tr></form>");
 
Page2.php-------------->
<?php
$_SESSION['ProjectSelect'] = $_POST['ProjectSelectArray'];
?>
 
<?php
print ("<form style=margin:0 id=SetExpenseDistributionForm name=SetExpenseDistributionForm method=post action=page3.php>
<table width=100% border=0 cellspacing=0 cellpadding=5>
<tr><td><a href=page1.php>Select Project(s)</a> >> <strong>Set Expense Allocation</strong> >> Select Expense Type >> Submit Expense Item</td></tr>
</table>
				
<table width=100% border=0 cellspacing=0 cellpadding=5>");
//Print errors if any
if (isset($formerror)) {
	print ("<tr><td class=error>$formerror</td></tr>");
}
					
print ("<tr><td><table width=100% border=0 cellspacing=0 cellpadding=5>");
$b = count($_SESSION['ProjectSelect']);
for ($j=0; $j<$b; $j++) {
	$ProjectID = $_SESSION['ProjectSelect'][$j];
 
	//Get Project Name
	$tsql = "SELECT * FROM Projects WHERE ProjectID=?";
	$stmt = sqlsrv_query($conn1, $tsql, array($ProjectID));
	$row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC);
	$ProjectName = $row[ProjectName];
												
	print ("<tr><td width=4%><input name=ProjectPercentArray[$j] type=text id=ProjectPercentArray[$j]></td>
		<td width=96%>%: $ProjectID: $ProjectName</td></tr>");
}
print ("</table></td></tr><tr><td><em>Expense Distribution Must Equal 100% </em></td></tr><tr><td>
	<table><tr><td width=100><input name=SetExpenseDistribution type=submit id=SetExpenseDistribution value=\"Continue\" ></td>
	<td><input type=button value=Cancel onClick=goToURL()></td></tr></table></td></tr></table></form>");
?>
[+][-]01/28/09 06:12 PM, ID: 23493750Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/28/09 06:17 PM, ID: 23493776Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/28/09 06:26 PM, ID: 23493822Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/28/09 06:34 PM, ID: 23493857Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/28/09 06:36 PM, ID: 23493870Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/28/09 06:48 PM, ID: 23493920Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/28/09 07:07 PM, ID: 23494019Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/28/09 07:19 PM, ID: 23494065Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/29/09 06:37 AM, ID: 23497742Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/29/09 06:41 AM, ID: 23497795Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/29/09 06:58 AM, ID: 23498018Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/29/09 07:35 AM, ID: 23498454Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/29/09 07:52 AM, ID: 23498646Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/29/09 08:17 AM, ID: 23498980Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/29/09 08:25 AM, ID: 23499075Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/29/09 09:40 AM, ID: 23500195Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/29/09 10:00 AM, ID: 23500441Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: PHP Scripting Language, PHP for Windows, Hypertext Markup Language (HTML)
Tags: PHP $_POST $_SESSION array
Sign Up Now!
Solution Provided By: Ray_Paseur
Participating Experts: 1
Solution Grade: A
 
[+][-]01/29/09 12:19 PM, ID: 23502046Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/29/09 12:36 PM, ID: 23502212Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/29/09 01:34 PM, ID: 23502899Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625