Page 1 of 1

passing a value from one form to another:need help

Posted: Wed Sep 01, 2010 5:39 am
by esandra
//i've been looking at this same code for two whole days now and ive changed it lots of times but it can only get worse
//i can't pass the value of the variable $today which has a date datatype
//this is the part where i get the value of $today
<?php
$query="SELECT DISTINCT today FROM arrastre order by today desc";
$result=mysql_query($query);
while($row=mysql_fetch_object($result)){
$today=$row->today;
echo "<option value=$today>$today</option>";
}
?>
//here's is the part where i use $today to get $tcl
//except for a major problem that when the while loop returns more than one $tcl, i get more than one button, but that's not the problem because that is how it's supposed to work. The problem is that when there are more than one buttons, only the last button would work, the only button that displays values
<?php
if(isset($_POST['godate'])){
$today=$_POST['today'];
$query="SELECT DISTINCT tcl FROM arrastre WHERE today='$today' ORDER BY tcl ASC";
$result=mysql_query($query);
while($row=mysql_fetch_array($result)){
$tcl=$row['tcl'];
$today=$row['today'];
?>
<input type="hidden" name="tcl" value="<?php echo $tcl;?>">
<input type=submit name="tcl" value="<?php echo $tcl; ?>">
<?php } }
?>

//thsi is another problem
if(isset($_POST['tcl'])){
$tcl=$_POST['tcl'];
$today=$_POST['today'];
$query = "select * from arrastre where tcl=$tcl and today='$today' order by tcl asc";
$result = mysql_query($query);
$totalcollections = 0;
while($row=mysql_fetch_array($result)){
$orno=$row['orno'];
$billnmbr=$row['billnmbr'];
$payor=$row['payor'];
$arrastre=$row['arrastre'];
$wharfage=$row['wharfage'];
$total=$row['total'];
$today=$row['today'];
//*i deleted the display part to make this shorter a little
}}
//the $today variable is empty in this post and i have no idea how to successfully pass this value
so i could use it in my $query
//thanks for your time

Re: passing a value from one form to another:need help

Posted: Wed Sep 01, 2010 6:09 am
by amargharat
<?php
$query="SELECT DISTINCT date FROM arrastre order by today desc";
$result=mysql_query($query);
while($row=mysql_fetch_object($result)){
$today=$row->today;
echo "<option value=$today>$today</option>";
}
?>
in above code u just have to change as follows,
$today=$row->date;

Re: passing a value from one form to another:need help

Posted: Wed Sep 01, 2010 7:20 am
by esandra
im so sorry i mistyped..that was supposed to be "select distinct today" not "select distinct date"
and ive already made the changes needed in my first post