swap_ssj
08-27-2009, 08:07 AM
Hello guyes…
I’m new in this PHP world.
I have tried in either ways, but it's not working for me.
I have to play with 3 values selected by user from the dropdown list, i.e. $_POST['plotid_1'],$_POST['year1'],$_POST['year2']. I'm not able to pass these values to query.
Here i'm posting my code :
<?php
session_start();
ob_start();
?>
<form name="form" id="form" method="post" action="index.php?page=report3" onsubmit="return
validateForms('form');">
<table width="60%" align="center" cellpadding="5" cellspacing="1" bgcolor="#CCCC99">
<tr bgcolor="#FFFFFF">
<td class="heading" colspan="2" align="center" bgcolor="#EEEEEE">PlotWise Yield Analysis</td>
</tr>
<tr bgcolor="#FFFFFF">
<td class="graytext" align="right">Season 1 : </td>
<td align="left"><select id="year1" name="year1">
<?php
$q1=mysql_query("select distinct season from seasonmaster");
while($rs1=mysql_fetch_array($q1))
{ if($_REQUEST["yid"]==$rs1[season]){
?>
<option value=" <?php echo $rs1[season];?> " selected="selected"><?php echo $rs1[season];?></option>
<?php } else{
?>
<option value="<?php echo $rs1[season];?>"><?php echo $rs1[season];?></option>
<?php }
} ?>
</select>
<span id="uname" class="rederr"></span>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td class="graytext" align="right">Season 2 : </td>
<td align="left"><select id="year2" name="year2">
<?php
$q1=mysql_query("select distinct season from seasonmaster");
while($rs1=mysql_fetch_array($q1))
{ if($_REQUEST["yid2"]==$rs1[season]){
?>
<option value="<?php echo $rs1[season];?>" selected="selected"><?php echo $rs1[season];?></option>
<?php } else{ ?>
<option value="<?php echo $rs1[season];?>"><?php echo $rs1[season];?></option>
<?php }
}?>
</select><br />
<span id="pass" class="rederr"></span>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td class="graytext" align="right">Plot No. :</td>
<td align="left"><select name="plotid_1" id="plotid_1">
<option value="0">--Select Plot--</option>
<?php
$Sql=mysql_query("SELECT * FROM plots ");
while($row = mysql_fetch_array($Sql))
{
if($_REQUEST["pid"]==$row[plotno])
echo "<option value=$row[plotno] selected>$row[plotno]</option>"; else
echo "<option value=$row[plotno]>$row[plotno]</option>"; }
if($_POST['plotid_1'])
{
$s1=mysql_query("select 'sid' from 'seasonmaster' where 'season'='".$_POST[year1]."'");
$rss1=mysql_fetch_array($s1);
$sql1=mysql_query("select sum(total)from 'actual_yield' where 'tid' in (SELECT 'tid' FROM 'treemaster' WHERE 'plotid'=(select 'plotid' from 'plots' where 'plotno'='".$_POST[plotid_1]."'))and 'sid'='".$rss1[sid]."'");
$rsAy=mysql_fetch_array($sql1);
session_register("actY1");
$_SESSION["actY1"]=$rsAy['total'];
$s2=mysql_query("select 'sid' from 'seasonmaster' where 'season'='".$_POST[year2]."'");
$rss2=mysql_fetch_array($s2);
$sql2=mysql_query("select sum(total)from 'actual_yield' where 'tid' in (SELECT 'tid' FROM 'treemaster' WHERE 'plotid'=(select 'plotid' from 'plots' where 'plotno'='".$_POST[plotid_1]."'))and 'sid'='".$rss2[sid]."'");
$rsAy1=mysql_fetch_array($sql2);
session_register("actY2");
$_SESSION["actY2"]=$rsAy1['total'];
}
?>
</select><br>
<span id="plotid" class="rederr"></span>
<td>
</tr>
<tr bgcolor="#FFFFFF">
<td class="heading" colspan="2" align="center"><input type="submit" class="button" name="save" id="save" value=" Show "></td>
</tr>
</table>
</form>
-----------------------------------------------------------------------------------------------------------------------------------------------------Here is my code. I have to play with 3 values selected by user from the dropdown list.
I'm doing it in this way, but it's not working.
How can i do this....???
I’m new in this PHP world.
I have tried in either ways, but it's not working for me.
I have to play with 3 values selected by user from the dropdown list, i.e. $_POST['plotid_1'],$_POST['year1'],$_POST['year2']. I'm not able to pass these values to query.
Here i'm posting my code :
<?php
session_start();
ob_start();
?>
<form name="form" id="form" method="post" action="index.php?page=report3" onsubmit="return
validateForms('form');">
<table width="60%" align="center" cellpadding="5" cellspacing="1" bgcolor="#CCCC99">
<tr bgcolor="#FFFFFF">
<td class="heading" colspan="2" align="center" bgcolor="#EEEEEE">PlotWise Yield Analysis</td>
</tr>
<tr bgcolor="#FFFFFF">
<td class="graytext" align="right">Season 1 : </td>
<td align="left"><select id="year1" name="year1">
<?php
$q1=mysql_query("select distinct season from seasonmaster");
while($rs1=mysql_fetch_array($q1))
{ if($_REQUEST["yid"]==$rs1[season]){
?>
<option value=" <?php echo $rs1[season];?> " selected="selected"><?php echo $rs1[season];?></option>
<?php } else{
?>
<option value="<?php echo $rs1[season];?>"><?php echo $rs1[season];?></option>
<?php }
} ?>
</select>
<span id="uname" class="rederr"></span>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td class="graytext" align="right">Season 2 : </td>
<td align="left"><select id="year2" name="year2">
<?php
$q1=mysql_query("select distinct season from seasonmaster");
while($rs1=mysql_fetch_array($q1))
{ if($_REQUEST["yid2"]==$rs1[season]){
?>
<option value="<?php echo $rs1[season];?>" selected="selected"><?php echo $rs1[season];?></option>
<?php } else{ ?>
<option value="<?php echo $rs1[season];?>"><?php echo $rs1[season];?></option>
<?php }
}?>
</select><br />
<span id="pass" class="rederr"></span>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td class="graytext" align="right">Plot No. :</td>
<td align="left"><select name="plotid_1" id="plotid_1">
<option value="0">--Select Plot--</option>
<?php
$Sql=mysql_query("SELECT * FROM plots ");
while($row = mysql_fetch_array($Sql))
{
if($_REQUEST["pid"]==$row[plotno])
echo "<option value=$row[plotno] selected>$row[plotno]</option>"; else
echo "<option value=$row[plotno]>$row[plotno]</option>"; }
if($_POST['plotid_1'])
{
$s1=mysql_query("select 'sid' from 'seasonmaster' where 'season'='".$_POST[year1]."'");
$rss1=mysql_fetch_array($s1);
$sql1=mysql_query("select sum(total)from 'actual_yield' where 'tid' in (SELECT 'tid' FROM 'treemaster' WHERE 'plotid'=(select 'plotid' from 'plots' where 'plotno'='".$_POST[plotid_1]."'))and 'sid'='".$rss1[sid]."'");
$rsAy=mysql_fetch_array($sql1);
session_register("actY1");
$_SESSION["actY1"]=$rsAy['total'];
$s2=mysql_query("select 'sid' from 'seasonmaster' where 'season'='".$_POST[year2]."'");
$rss2=mysql_fetch_array($s2);
$sql2=mysql_query("select sum(total)from 'actual_yield' where 'tid' in (SELECT 'tid' FROM 'treemaster' WHERE 'plotid'=(select 'plotid' from 'plots' where 'plotno'='".$_POST[plotid_1]."'))and 'sid'='".$rss2[sid]."'");
$rsAy1=mysql_fetch_array($sql2);
session_register("actY2");
$_SESSION["actY2"]=$rsAy1['total'];
}
?>
</select><br>
<span id="plotid" class="rederr"></span>
<td>
</tr>
<tr bgcolor="#FFFFFF">
<td class="heading" colspan="2" align="center"><input type="submit" class="button" name="save" id="save" value=" Show "></td>
</tr>
</table>
</form>
-----------------------------------------------------------------------------------------------------------------------------------------------------Here is my code. I have to play with 3 values selected by user from the dropdown list.
I'm doing it in this way, but it's not working.
How can i do this....???