mishuk Posted April 17, 2007 Share Posted April 17, 2007 I am working with graphs that get their results from a table in the database but first the user will select a year the reports are to be produced for. The user selects a year from the page. This is submitted and the next page which populates a variable $year with the value from ($_POST['year']). This page then produces the result of the query for the year specified into a table. I then have a seperate php file that stores the query again and produces a graph for the relevant query. However i can not pass the $_POST variable to the file that contains the graph. ----------------------------------------- report.php------------------------------ $year = ($_POST['year']); ?> <br> <TABLE BORDER="1" CELLSPACING="0" CELLPADDING="5" ALIGN="center" BORDERCOLOR="#C8C8C8"> <tr> <td colspan="2" bgcolor="#F1F1F1">1. On a scale of 1 to 10, how useful did the learners find the Thackray Days?</td> </tr> <tr> <td><? $query_string = "SELECT q1, count(q1) FROM tbl_y9 WHERE q1 IS NOT NULL AND year = $year GROUP BY q1 Order By q1 ASC"; $result_id = mysql_query($query_string); $column_count = mysql_num_fields($result_id); print("<TABLE BORDER=1 ALIGN=center BORDERCOLOR=\"#C8C8C8\" cellspacing=0 cellpadding=2>\n"); print("<TR>"); print("<TD BGCOLOR = #F1F1F1>Rating</TD>\n"); print("<TD BGCOLOR = #F1F1F1>Rating Count</TD>\n"); print("</TR>"); while ($row = mysql_fetch_row($result_id)) { print("<TR ALIGN=center VALIGN=TOP>"); for ($column_num = 0; $column_num < $column_count; $column_num++) print("<TD BGCOLOR = #FFFFFF>$row[$column_num]</TD>\n"); print ("</TR>\n"); } print ("</TABLE>\n"); ?> </td> <td><p align = "center"><img src="/careers/graph/y9q1.php"></p></td> </tr> <tr> ------------------------------------------------------------------------------------------- ------------------------------------------ y9q1.php --------------------------------- include ("../includes/db_connect.php"); include('../includes/postgraph.class.php'); $query = "SELECT q1, count(q1) FROM tbl_y9 WHERE q1 IS NOT NULL GROUP BY q1 Order By q1 ASC"; $result = mysql_query($query) or die(mysql_error()); code continues --------------------------------------------------------------------------------------------- How can i pass the $_post variable into y9q1.php as well as passing it to reports.php Hope this makes sence. Thanks Link to comment https://forums.phpfreaks.com/topic/47392-global-variable-problem/ Share on other sites More sharing options...
veridicus Posted April 17, 2007 Share Posted April 17, 2007 You can't directly get to your $_POST from y9q1.php. You could put together a query string when you call the script and get to the data through $_GET. But to hide the info from the page you could store the $_POST data you need in a session variable or cookie, which y9q1.php would also have access to. As for getting $_POST data from report.php, it has to be called from a POST. How is report.php executed? Link to comment https://forums.phpfreaks.com/topic/47392-global-variable-problem/#findComment-231216 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.