Jump to content

$_POST variable


searls03

Recommended Posts

ok, so here is what I have so far

<?php
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT SUM(price) as price FROM transactions where Academy = '$_POST['academy']' AND month='".$date1."'");
while($row = mysql_fetch_array($sql)){
$price = $row["price"];
echo $price;}
?>

I would like to use a drop down menu that when selected, it would change the $_POST['academy'] to the selected value of the dropdown.  I don't want the page to refresh either.  how could I do this?

Link to comment
https://forums.phpfreaks.com/topic/264403-_post-variable/
Share on other sites

ok I am using this:

<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
<script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("#form1").validate({
		debug: false,

		submitHandler: function(form) {
			// do other stuff for a valid form
			$.post('graph.php', $("#form1").serialize(), function(data) {
			$("#apDiv3").load("graph.php #apDiv3");	$("#apDiv8").load("graph.php #apDiv8");
			});
		}
	});
});
</script>

and this:

 <form id="form1" method="post">
    <select name="academy" onchange="this.form.submit()">
      <option value="Old_Cheney">Old Cheney</option>
      <option value="Yankee_HIll">Yankee Hill</option>
      <option value="Holdrege">Holdrege</option>
      <option value="Center">Center</option>
      <option value="Maple">Maple</option>
    </select>
  </form>

and this is the divs it should load:

<div id="apDiv3">
  <p>
  <script type="text/javascript">
// BeginOAWidget_Instance_2281525: #jQueryVisualizeChart

   	$(function(){
	 $('#table').visualize({type: 'line', height: '300px', width: '420px', appendTitle : true, lineWeight : 4, colors : ['#be1e2d','#666699','#92d5ea','#ee8310','#8d10ee','#5a3b16','#26a4ed','#f45a90','#e9e744']}).appendTo('#jQueryVisualizeChart').trigger('visualizeRefresh');

	});

// EndOAWidget_Instance_2281525
    </script>
  <div id="jQueryVisualizeChart"></div>
  <script type="text/javascript">
// BeginOAWidget_Instance_2281525: #jQueryVisualizeChart_2

   	$(function(){
	 $('#table').visualize({type: 'bar', height: '300px', width: '420px', appendTitle : true, lineWeight : 4, colors : ['#be1e2d','#666699','#92d5ea','#ee8310','#8d10ee','#5a3b16','#26a4ed','#f45a90','#e9e744']}).appendTo('#jQueryVisualizeChart_2').trigger('visualizeRefresh');

	});

// EndOAWidget_Instance_2281525
  </script>
  
  <br />
  <table id="table" style="display:none">
    <caption> 
    </caption>
    <thead>
      <tr>
        <td></td>
       <th scope="col"><?php $date1= date("F Y", strtotime("-5 months")); echo $date1 ?></th>
        <th scope="col"><?php $date2= date("F Y", strtotime("-4 months")); echo $date2 ?></th>
        <th scope="col"><?php $date3= date("F Y", strtotime("-3 months")); echo $date3 ?></th>
        <th scope="col"><?php $date4= date("F Y", strtotime("-2 months")); echo $date4 ?></th>
        <th scope="col"><?php $date5= date("F Y", strtotime("-1 months")); echo $date5 ?></th>
        <th scope="col"><?php $date6= date("F Y", strtotime("-0 months")); echo $date6 ?></th>
      </tr>
    </thead>
    <tbody>
    <th scope="row">Old Cheney</th>
        <td> <?php
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT SUM(price) as price FROM transactions where Academy = '".$_POST['academy']."' AND month='".$date1."'");
while($row = mysql_fetch_array($sql)){
$price = $row["price"];
echo $price;}
?></td>
        <td><?php
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT SUM(price) as price FROM transactions where Academy = '".$_POST['academy']."' AND month='".$date2."'");
while($row = mysql_fetch_array($sql)){
$price2 = $row["price"];
echo $price2;}
?></td>
        <td><?php
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT SUM(price) as price FROM transactions where Academy = '".$_POST['academy']."' AND month='".$date3."'");
while($row = mysql_fetch_array($sql)){
$price3 = $row["price"];
echo $price3;}
?></td> <td><?php
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT SUM(price) as price FROM transactions where Academy = '".$_POST['academy']."' AND month='".$date4."'");
while($row = mysql_fetch_array($sql)){
$price4 = $row["price"];
echo $price4;}
?></td><td><?php
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT SUM(price) as price FROM transactions where Academy = '".$_POST['academy']."' AND month='".$date5."'");
while($row = mysql_fetch_array($sql)){
$price5 = $row["price"];
echo $price5;}
?></td>
<td><?php
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT SUM(price) as price FROM transactions where Academy = '".$_POST['academy']."' AND month='".$date6."'");
while($row = mysql_fetch_array($sql)){
$price6 = $row["price"];
echo $price6;}
?></td>
      
      </tr>
      
  </table>
  <p><br />
</p>
</div>


<div id="apDiv8"><div id="jQueryVisualizeChart_2"></div></div>

 

yet, the page is still refreshing...does anyone see why?

Link to comment
https://forums.phpfreaks.com/topic/264403-_post-variable/#findComment-1355018
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.