Jump to content

tlavelle

Members
  • Posts

    73
  • Joined

  • Last visited

    Never

Everything posted by tlavelle

  1. Thanks I stuck this in if(isset($_POST['wercbench1_next'])){ $_SESSION['sess_year']=$_POST['year']; echo $_SESSION['sess_year']; } Seemed to fix it Sound correct?
  2. This file has 3 forms in it. Form 1 - presents to all users. Users select a year and submit Form 2 - Is conditional. It only shows if users choose the value '2007' Form 3 - Should present to all users For whatever reason, my session variable for year seems to get lost after a user who selects 2007 in the first form submits the second form. Help? <?php //initialize session session_start(); ?> <html> <head> <basefont face="Arial"> </head> <body> <?php // set server access variables $host = "localhost"; $user = "root"; $pass = ""; $db = "wercbench"; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create form 1 queries $year_query = "SELECT distinct year FROM bench_data"; // execute form 1 queries $year_result = mysql_query($year_query) or die ("Error in query: $query. ".mysql_error()); // grab distinct years from db and stick them in the drop down if (mysql_num_rows($year_result) > 0){ if (!isset($_POST['wercbench1']) and !isset($_POST['year']) || !isset($_POST['wercbench2']) and !isset($_POST['year'])) { echo"<form method=\"POST\" action=\"". $_SERVER['PHP_SELF']. "\" name=\"wercbench1\">"; echo"<table style=\"width: 300;\" border=\"1\" cellpadding=\"2\" cellspacing=\"2\">"; echo"<tbody>"; echo" <tr>"; echo" <td>Select the comparison year and then click next"; echo" </td>"; echo" <td></td>"; echo" </tr>"; echo" <tr>"; echo" <td>"; echo" <select name=\"year\">"; while($row = mysql_fetch_row($year_result)) { echo"<option value=\"" .$row[0]. "\">".$row[0]."</option>"; } echo" </select>"; echo" </td>"; echo" <td></td>"; echo" </tr><tr>"; echo" <td><input type=\"Submit\" value=\"Next\" name=\"wercbench1_next\"></button></td>"; echo" </tr>"; echo" </form>"; } $_SESSION['sess_year']=$_POST['year']; echo $_SESSION['sess_year']; //if 2005 is selected just show the data if(isset($_POST['wercbench1_next']) && ($_SESSION['sess_year']!='2005')){ $industry_result = mysql_query("SELECT distinct comp_desc FROM comp_desc") or die(mysql_error()); echo" <tr>"; echo"<form method=\"POST\" action=\"". $_SERVER['PHP_SELF']. "\" name=\"wercbench2\">"; echo" <td>"; echo" <select name=\"industry\">"; while($row = mysql_fetch_row($industry_result)) { echo"<option value=\"" .$row[0]. "\">".$row[0]."</option>"; } echo" </select>"; echo"</td>"; echo" <td></td>"; echo" </tr>"; echo" <tr>"; echo" <td><input type=\"Submit\" value=\"Next\" name=\"wercbench2_next\"></button></td>"; echo" <td></td>"; echo" </tr>"; echo"</tbody>"; echo"</table>"; echo"</form>"; } $_SESSION['sess_industry']=$_POST['industry']; } else { // no // print status message echo "No rows found!"; } if( (isset($_POST['wercbench2_next']) and ($_SESSION['sess_year']=='2007')) or (isset($_POST['wercbench1_next']) and ($_SESSION['sess_year']=='2005')) ) { $useryear=$_SESSION['sess_year']; //$_SESSION['sess_year']=$_POST['year']; $userindustry=$_SESSION['sess_industry']; //$_SESSION['sess_ind']=$_POST['industry']; $metric_query = "SELECT metric_desc.met_desc, bench_data.median, bench_data.best_pract FROM metric_desc, bench_data where metric_desc.met_key=bench_data.met_key and $useryear=bench_data.year"; $metric_result = mysql_query($metric_query) or die ("Error in query: $query. ".mysql_error()); echo $_SESSION['sess_year']; echo $_SESSION['sess_industry']; echo "<form action=\"results.php\" method=\"post\" name\"wercbench3\">"; echo "<table cellpadding=10 border=1>"; echo "<tr>"; echo "<td>Metric Description</td>"; echo "<td>Average</td>"; echo "<td>Best Practice</td>"; echo "<td>Enter your value here</td>"; echo "</tr>"; while($row = mysql_fetch_row($metric_result)) { echo "<tr>"; echo "<td>".$row[0]."</td>"; echo "<td>" . $row[1]."</td>"; echo "<td>".$row[2]."</td>"; echo "<td><input type=\"text\" name=\"myvalue[]\" value=\"\" /></td>"; echo "</tr>"; } echo "<tr><td colspan=\"3\"> </td><td align=\"center\"><input type=\"submit\" name=\"wercbench3\" value=\"Compare\"></td></tr></table>"; //} // free result set memory mysql_free_result($year_result); //mysql_free_result($industry_result); mysql_free_result($metric_result); //mysql_free_result($metric_result); } // close connection mysql_close($connection); ?> </body> </html>
  3. is there a way to link to a location on a page like in the example below but instead of the link existing on the same page as the target location, the link exist on one page and points to a bookmark on another page? So for example, I want index.html to have a link that takes the user to chapter 4 of content.html (which is half way down the page) <p> <a href="#C4">See also Chapter 4.</a> </p> <h2>Chapter 1</h2> <p>This chapter explains ba bla bla</p> <h2>Chapter 2</h2> <p>This chapter explains ba bla bla</p> <h2>Chapter 3</h2> <p>This chapter explains ba bla bla</p> <h2><a name="C4">Chapter 4</a></h2> <p>This chapter explains ba bla bla</p>
  4. What is wrong with this sql? use imis; select count(id) as duescount , id from activity where activity_type='dues' and duescount>=2 group by id order by duescount asc; it is giving me this Msg 207, Level 16, State 3, Line 2 Invalid column name 'duescount'. Can you not sue an alias like this? If not, how do I make that comparison?
  5. There are 2 if statements at the beginning of this code snippet. The one that is currently commented out works while the one that is not commented out yields this error Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\bench2\index4.php on line 106 I am just not seeing why. Help please? //if((isset($_POST['wercbench2_next']) and ($_POST['year']='2007')) or $_POST['year']='2005'){ if((isset($_POST['wercbench2_next']) and ($_POST['year']='2007')) or (isset($_POST['wercbench1_next']) and ($_POST['year']='2005')) { $useryear=$_POST['year']; $_SESSION['sess_year']=$_POST['year']; $userindustry=$_POST['industry']; $_SESSION['sess_ind']=$_POST['industry']; $metric_query = "SELECT metric_desc.met_desc, bench_data.median, bench_data.best_pract FROM metric_desc, bench_data where metric_desc.met_key=bench_data.met_key and $useryear=bench_data.year"; //$metric_query = "SELECT metric_desc.met_desc, bench_data.median, bench_data.best_pract FROM metric_desc, bench_data where metric_desc.met_key=bench_data.met_key and $useryear=bench_data.year and $userindustry=bench_data.comp_key"; $metric_result = mysql_query($metric_query) or die ("Error in query: $query. ".mysql_error()); if(isset($_POST['wercbench2_next']) and (mysql_num_rows($metric_result)) > 0){ // yes // print them one after another //echo "<form action=\"results.php\" method=\"post\" name\"wercbench2\">"; echo "<form action=\"results.php\" method=\"post\" name\"wercbench3\">"; echo "<table cellpadding=10 border=1>"; echo "<tr>"; echo "<td>Metric Description</td>"; echo "<td>Average</td>"; echo "<td>Best Practice</td>"; echo "<td>Enter your value here</td>"; echo "</tr>"; while($row = mysql_fetch_row($metric_result)) { echo "<tr>"; echo "<td>".$row[0]."</td>"; echo "<td>" . $row[1]."</td>"; echo "<td>".$row[2]."</td>"; echo "<td><input type=\"text\" name=\"myvalue[]\" value=\"\" /></td>"; echo "</tr>"; } echo "<tr><td colspan=\"3\"> </td><td align=\"center\"><input type=\"submit\" name=\"wercbench3\" value=\"Compare\"></td></tr></table>"; } // free result set memory mysql_free_result($year_result); //mysql_free_result($industry_result); mysql_free_result($metric_result); //mysql_free_result($metric_result); }
  6. Session variables allow you to capture user entered values for the duration of the users session. At the top of all the pages in your app, make sure you include <?php session_start(); ?> This basically allows you to invoke the session array. So if a user posts a value from a form you can assign it to $_SESSION['dvd']; Then for the duration of the session, that variable will be available in that array.
  7. if(isset($_POST['wercbench2_next'] && isset$_POST['year']='2007') || $_POST['year']='2005') why is it giving me this? Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ',' or ')' in C:\xampp\htdocs\bench2\index4.php on line 105
  8. How do you guys do this without smashing your computer and burning all code in a huge effigy? I am ready to give up on this forever!! Curse you PHP and your endless taunting of me!!
  9. But it should always be empty when the page loads. That variable should not be populated until the user posts form 1. I guess I don't understand why that code is being triggered at all. Should the conditional if insulate that code from being triggered until the a form is posted?
  10. I am getting this error: Error in query: . You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=bench_data.year' at line 1 Related to this snippet if(isset($_POST['wercbench2']) || ($_POST['year']<>'2005')) { $useryear=$_POST['year']; $_SESSION['sess_year']=$_POST['year']; $userindustry=$_POST['industry']; $_SESSION['sess_ind']=$_POST['industry']; $metric_query = "SELECT metric_desc.met_desc, bench_data.median, bench_data.best_pract FROM metric_desc, bench_data where metric_desc.met_key=bench_data.met_key and $useryear=bench_data.year"; $metric_result = mysql_query($metric_query) or die ("Error in query: $query. ".mysql_error()); In this file <?php //initialize session session_start(); ?> <html> <head> <basefont face="Arial"> </head> <body> <?php // set server access variables $host = "localhost"; $user = "root"; $pass = ""; $db = "wercbench"; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create form 1 queries $year_query = "SELECT distinct year FROM bench_data"; // execute form 1 queries $year_result = mysql_query($year_query) or die ("Error in query: $query. ".mysql_error()); //$industry_result = mysql_query($industry_query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($year_result) > 0){ // yes // print them one after another if (!isset($_POST['wercbench1']) and !isset($_POST['year'])) { /*" name=\"wercbench1\">";*/ echo"<form method=\"POST\" action=\"". $_SERVER['PHP_SELF']. "\" name=\"wercbench1\">"; echo"<table style=\"width: 100%;\" border=\"1\" cellpadding=\"2\" cellspacing=\"2\">"; echo"<tbody>"; echo" <tr>"; echo" <td>Select the comparison year and group then click next"; echo" </td>"; echo" <td></td>"; echo" </tr>"; echo" <tr>"; echo" <td>"; echo" <select name=\"year\">"; while($row = mysql_fetch_row($year_result)) { echo"<option value=\"" .$row[0]. "\">".$row[0]."</option>"; } echo" </select>"; echo" </td>"; echo" <td></td>"; echo" </tr><tr>"; echo" <td><input type=\"Submit\" value=\"Next\" name=\"wercbench1_next\"></button></td>"; echo" </tr>"; echo" </form>"; } if(isset($_POST['wercbench1_next']) && !empty($_POST['year'])){ if ($_POST['year']<>'2005'){ $industry_result = mysql_query("SELECT distinct comp_desc FROM comp_desc") or die(mysql_error()); echo" <tr>"; echo"<form method=\"POST\" action=\"". $_SERVER['PHP_SELF']. "\" name=\"wercbench2\">"; echo" <td>"; echo" <select name=\"industry\">"; while($row = mysql_fetch_row($industry_result)) { echo"<option value=\"" .$row[0]. "\">".$row[0]."</option>"; } echo" </select>"; echo"</td>"; echo" <td></td>"; echo" </tr>"; echo" <tr>"; echo" <td><input type=\"Submit\" value=\"Next\" name=\"wercbench2_next\"></button></td>"; echo" <td></td>"; echo" </tr>"; echo"</tbody>"; echo"</table>"; echo"</form>"; } } } else { // no // print status message echo "No rows found!"; } //Calcualtor variables if(isset($_POST['wercbench2']) || ($_POST['year']<>'2005')) { $useryear=$_POST['year']; $_SESSION['sess_year']=$_POST['year']; $userindustry=$_POST['industry']; $_SESSION['sess_ind']=$_POST['industry']; $metric_query = "SELECT metric_desc.met_desc, bench_data.median, bench_data.best_pract FROM metric_desc, bench_data where metric_desc.met_key=bench_data.met_key and $useryear=bench_data.year"; $metric_result = mysql_query($metric_query) or die ("Error in query: $query. ".mysql_error()); if(isset($_POST['wercbench2_next']) and (mysql_num_rows($metric_result)) > 0){ // yes // print them one after another //echo "<form action=\"results.php\" method=\"post\" name\"wercbench2\">"; echo "<form action=\"results.php\" method=\"post\" name\"wercbench3\">"; echo "<table cellpadding=10 border=1>"; echo "<tr>"; echo "<td>Metric Description</td>"; echo "<td>Average</td>"; echo "<td>Best Practice</td>"; echo "<td>Enter your value here</td>"; echo "</tr>"; while($row = mysql_fetch_row($metric_result)) { echo "<tr>"; echo "<td>".$row[0]."</td>"; echo "<td>" . $row[1]."</td>"; echo "<td>".$row[2]."</td>"; echo "<td><input type=\"text\" name=\"myvalue[]\" value=\"\" /></td>"; echo "</tr>"; } echo "<tr><td colspan=\"3\"> </td><td align=\"center\"><input type=\"submit\" name=\"wercbench3\" value=\"Compare\"></td></tr></table>"; } // free result set memory mysql_free_result($year_result); mysql_free_result($industry_result); mysql_free_result($metric_result); //mysql_free_result($metric_result); } // close connection mysql_close($connection); ?> </body> </html> I dont see how the query is even being triggered upon initial load of this page to cause the error.
  11. Instead of saying the main form, I should say teh third form in the code. Basically the logic is 1. Select a year 2. If the year is 2007, select an industry 3. IF the year is 2005 or the year is 2007 and an industry is selected, show form 3 it is step 3 above that is not working
  12. Can you site the specific non-sensical line? is this it? if(!isset($_POST['wercbench2_next']) and (mysql_num_rows($metric_result)) > 0)
  13. OK. So I am attempting to create a list box that is dynamically populated based on the selection of another list box. I am in way over my head..only way to learn I guess. The code below has a year listbox and then based on the year selection, the page should either show another listbox (show industry selection when year <> 2005) or it should render the main form (when year=2005). I cannot get the main form to appear. Help please? <?php //initialize session session_start(); ?> <html> <head> <basefont face="Arial"> </head> <body> <?php // set server access variables $host = "localhost"; $user = "root"; $pass = ""; $db = "wercbench"; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create form 1 queries $year_query = "SELECT distinct year FROM bench_data"; // execute form 1 queries $year_result = mysql_query($year_query) or die ("Error in query: $query. ".mysql_error()); //$industry_result = mysql_query($industry_query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($year_result) > 0){ // yes // print them one after another if (!isset($_POST['wercbench1']) and !isset($_POST['year'])) { /*" name=\"wercbench1\">";*/ echo"<form method=\"POST\" action=\"". $_SERVER['PHP_SELF']. "\" name=\"wercbench1\">"; echo"<table style=\"width: 100%;\" border=\"1\" cellpadding=\"2\" cellspacing=\"2\">"; echo"<tbody>"; echo" <tr>"; echo" <td>Select the comparison year and group then click next"; echo" </td>"; echo" <td></td>"; echo" </tr>"; echo" <tr>"; echo" <td>"; echo" <select name=\"year\">"; while($row = mysql_fetch_row($year_result)) { echo"<option value=\"" .$row[0]. "\">".$row[0]."</option>"; } echo" </select>"; echo" </td>"; echo" <td></td>"; echo" </tr><tr>"; echo" <td><input type=\"Submit\" value=\"Next\" name=\"wercbench1_next\"></button></td>"; echo" </tr>"; echo" </form>"; } if(isset($_POST['wercbench1_next']) && !empty($_POST['year'])){ if ($_POST['year']<>'2005'){ $industry_result = mysql_query("SELECT distinct comp_desc FROM comp_desc") or die(mysql_error()); echo" <tr>"; echo"<form method=\"POST\" action=\"". $_SERVER['PHP_SELF']. "\" name=\"wercbench2_next\">"; echo" <td>"; echo" <select name=\"industry\">"; while($row = mysql_fetch_row($industry_result)) { echo"<option value=\"" .$row[0]. "\">".$row[0]."</option>"; } echo" </select>"; echo"</td>"; echo" <td></td>"; echo" </tr>"; echo" <tr>"; echo" <td><input type=\"Submit\" value=\"Next\" name=\"wercbench2_next\"></button></td>"; echo" <td></td>"; echo" </tr>"; echo"</tbody>"; echo"</table>"; echo"</form>"; } } } else { // no // print status message echo "No rows found!"; } //Calcualtor variables if(isset($_POST['wercbench2_next'])) { $useryear=$_POST['year']; $_SESSION['sess_year']=$_POST['year']; $userindustry=$_POST['industry']; $_SESSION['sess_ind']=$_POST['industry']; $metric_query = "SELECT metric_desc.met_desc, bench_data.median, bench_data.best_pract FROM metric_desc, bench_data where metric_desc.met_key=bench_data.met_key and $useryear=bench_data.year"; $metric_result = mysql_query($metric_query) or die ("Error in query: $query. ".mysql_error()); if(!isset($_POST['wercbench2_next']) and (mysql_num_rows($metric_result)) > 0){ // yes // print them one after another //echo "<form action=\"results.php\" method=\"post\" name\"wercbench2\">"; echo "<form action=\"results.php\" method=\"post\" name\"wercbench2\">"; echo "<table cellpadding=10 border=1>"; echo "<tr>"; echo "<td>Metric Description</td>"; echo "<td>Average</td>"; echo "<td>Best Practice</td>"; echo "<td>Enter your value here</td>"; echo "</tr>"; while($row = mysql_fetch_row($metric_result)) { echo "<tr>"; echo "<td>".$row[0]."</td>"; echo "<td>" . $row[1]."</td>"; echo "<td>".$row[2]."</td>"; echo "<td><input type=\"text\" name=\"myvalue[]\" value=\"\" /></td>"; echo "</tr>"; } echo "<tr><td colspan=\"3\"> </td><td align=\"center\"><input type=\"submit\" name=\"wercbench_next2\" value=\"Compare\"></td></tr></table>"; } // free result set memory mysql_free_result($year_result); mysql_free_result($industry_result); mysql_free_result($metric_result); //mysql_free_result($metric_result); } // close connection mysql_close($connection); ?> </body> </html>
  14. How do I populate the second listbox in this form based on the selection of the first listbox? The first listbox is populated by this query: $year_query = "SELECT distinct year FROM bench_data"; The second listbox should essentially be populated by this: $industry_query = "SELECT distinct comp_desc FROM comp_desc, benc_data where $_POST['year']=bench_data.year and bench_data.comp_key=comp_desc.comp_key"; I know this is alot to ask, but please EXPLAIN the code. I am new and need the explanation elucidated and not just supplied code that will accomplish the goal. Thanks <?php //initialize session session_start(); ?> <html> <head> <basefont face="Arial"> </head> <body> <?php // set server access variables $host = "localhost"; $user = "root"; $pass = ""; $db = "wercbench"; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create form 1 queries $year_query = "SELECT distinct year FROM bench_data"; $industry_query = "SELECT distinct comp_desc FROM comp_desc"; // execute form 1 queries $year_result = mysql_query($year_query) or die ("Error in query: $query. ".mysql_error()); $industry_result = mysql_query($industry_query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($year_result) > 0){ // yes // print them one after another if (!isset($_POST['wercbench1']) and !isset($_POST['year'])) { /*" name=\"wercbench1\">";*/ echo"<form method=\"POST\" action=\"". $_SERVER['PHP_SELF']. "\" name=\"wercbench1\">"; echo"<table style=\"width: 100%;\" border=\"1\" cellpadding=\"2\" cellspacing=\"2\">"; echo"<tbody>"; echo" <tr>"; echo" <td>Select the comparison year and group then click next"; echo" </td>"; echo" <td></td>"; echo" </tr>"; echo" <tr>"; echo" <td>"; echo" <select name=\"year\">"; while($row = mysql_fetch_row($year_result)) { echo"<option value=\"" .$row[0]. "\">".$row[0]."</option>"; } echo" </select>"; echo" </td>"; echo" <td></td>"; echo" </tr>"; echo" <tr>"; echo" <td>"; echo" <select name=\"industry\">"; while($row = mysql_fetch_row($industry_result)) { echo"<option value=\"" .$row[0]. "\">".$row[0]."</option>"; } echo" </select>"; echo"</td>"; echo" <td></td>"; echo" </tr>"; echo" <tr>"; echo" <td><input type=\"Submit\" value=\"Next\" name=\"wercbench1_next\"></button></td>"; echo" <td></td>"; echo" </tr>"; echo"</tbody>"; echo"</table>"; echo"</form>"; } } else { // no // print status message echo "No rows found!"; } //Calcualtor variables if(isset($_POST['wercbench1_next'])) { $useryear=$_POST['year']; $_SESSION['sess_year']=$_POST['year']; $userindustry=$_POST['industry']; $_SESSION['sess_ind']=$_POST['industry']; $metric_query = "SELECT metric_desc.met_desc, bench_data.median, bench_data.best_pract FROM metric_desc, bench_data where metric_desc.met_key=bench_data.met_key and $useryear=bench_data.year"; $metric_result = mysql_query($metric_query) or die ("Error in query: $query. ".mysql_error()); if(!isset($_POST['wercbench2']) and (mysql_num_rows($metric_result)) > 0){ // yes // print them one after another //echo "<form action=\"results.php\" method=\"post\" name\"wercbench2\">"; echo "<form action=\"results.php\" method=\"post\" name\"wercbench2\">"; echo "<table cellpadding=10 border=1>"; echo "<tr>"; echo "<td>Metric Description</td>"; echo "<td>Average</td>"; echo "<td>Best Practice</td>"; echo "<td>Enter your value here</td>"; echo "</tr>"; while($row = mysql_fetch_row($metric_result)) { echo "<tr>"; echo "<td>".$row[0]."</td>"; echo "<td>" . $row[1]."</td>"; echo "<td>".$row[2]."</td>"; echo "<td><input type=\"text\" name=\"myvalue[]\" value=\"\" /></td>"; echo "</tr>"; } echo "<tr><td colspan=\"3\"> </td><td align=\"center\"><input type=\"submit\" name=\"wercbench_next2\" value=\"Compare\"></td></tr></table>"; } // free result set memory mysql_free_result($year_result); mysql_free_result($industry_result); mysql_free_result($metric_result); //mysql_free_result($metric_result); } // close connection mysql_close($connection); ?> </body> </html>
  15. Thank you very very much for that explanation. That totally elucidated the snippet for me. Thanks for the lesson.
  16. Thanks again. Please be a little more specific in your response. I am pretty new and pretty thick. Ambiguous pronouns such as "it" aren't specific enough.
  17. Thanks for the response. I am not sure what it means. Is there a white paper or article you can point me to? I guess I am looking for a step by step tutorial on it.
  18. I have just a general question about how to integrate applications without requiring separate logins for users. For example, lets say I had elgg installed but wanted to integrate phpbb. Is there a general way to integrate separate applications such that the elgg login and session extend to phpbb? Is there a general approach to invoke when building this sort of frankenapp?
  19. Could someone please explain the code snippet below line by line? I especially am interested in the last line. Is that a multidimensional array? How does the foreach() iterate across it? Thanks $_SESSION['Posted_values'] = array(); foreach($_POST as $fld => $val) $_SESSION['Posted_values'][$fld] = $val;
  20. I am sorry. I am not following those last 2 comments. What do you want as an associative array? and what list of unamed variables are you referring to?
  21. Hell I've learned something. I didn't realize you could name your fields (in HTML) as myvalue[] for example and it will force the value into an array. I guess I've never really had a need to but it could be useful. Yes...please expalin this moire. I don't understand hwo this works
  22. Thanks...A few questions. I just cannot wrap my mind around this Each textbox in the form has a name of $myvalue[] so the name of each textbox is an array variable? Does the posting of that form create the index values for each array element? How do the name value pairs get generated? also, what is this? . $_SESSION['Posted_values']['myvalue'][$i] . I understand $_SESSION['Posted_values'] is one array I am not really sure what ['myvalue'] is. IS this an additional index for a 2 dimensional array? And I get what $i is What statement assigns the values of the textboxes to the $myvalue array?
  23. I'm sorry. I am just not wrapping my head around this. This code <?php session_start(); ?> <html> <head> <basefont face="Arial"> </head> <body> <?php // set server access variables $host = "localhost"; $user = "root"; $pass = ""; $db = "wercbench"; $useryear=$_SESSION['sess_year']; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); //define Query $metric_query = "SELECT metric_desc.met_desc, userdata.median, userdata.best_pract FROM metric_desc, userdata where metric_desc.met_key=userdata.met_key and $useryear=userdata.year"; //execute query $metric_result = mysql_query($metric_query) or die ("Error in query: $query. ".mysql_error()); if(!isset($_POST['wercbench2']) and (mysql_num_rows($metric_result)) > 0){ echo "<form action=\"results.php\" method=\"post\" name\"wercbench2\">"; echo "<table cellpadding=10 border=1>"; echo "<tr>"; echo "<td>Metric Description</td>"; echo "<td>Average</td>"; echo "<td>Best Practice</td>"; echo "<td>Your Data</td>"; echo "<td>Your Data compared to Best Practice</td>"; echo "</tr>"; //create index for $myvalue array based on number of results returned from $metric_result query $len = mysql_num_rows($metric_result); for( $i = 0; $i < $len; ++$i ) { $row = mysql_fetch_row($metric_result); echo "<tr>"; echo "<td>" . $row[0]. "</td>"; echo "<td>" . $row[1]. "</td>"; echo "<td>" . $row[2]. "</td>"; echo "<td>" . $_SESSION['Posted_values']['myvalue']. "</td>"; echo "</tr>"; } } $_SESSION['Posted_values'] = array(); foreach($_POST as $fld => $val) $_SESSION['Posted_values'][$fld] = $val; echo '<pre>' . print_r($_SESSION,true) . '</pre>'; ?> </body> </html> is now yielding these results Array ( [Posted_values] => Array ( [myvalue] => Array ( [0] => 6 [1] => 6 [2] => 6 [3] => 6 [4] => 6 [5] => 6 [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] => ) [wercbench_next2] => Compare ) [sess_year] => 2005 [sess_ind] => All ) Metric Description Average Best Practice Your Data Your Data compared to Best Practice On time receipts 0.92 0.98 Array On time shipments 0.98 0.99 Array Fill rate-line 0.96 0.99 Array Fill rate-order 0.96 0.99 Array % of orders shipped complete 0.96 0.99 Array % of overtime hours 0.1 0.04 Array Days of raw materials on hand 20 10 Array . . . . . .
  24. $myvalue comes from user entered data from the first form in the first file.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.