esandra Posted September 1, 2010 Share Posted September 1, 2010 //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 Quote Link to comment https://forums.phpfreaks.com/topic/212278-passing-a-value-from-one-form-to-anotherneed-help/ Share on other sites More sharing options...
sasa Posted September 1, 2010 Share Posted September 1, 2010 change this part of code <?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 } } ?> with <?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); echo '<form method="POST"><input type="hidden" name="today" value="', $today, '">'; while($row=mysql_fetch_array($result)){ $tcl=$row['tcl']; $today=$row['today']; ?> <input type="submit" name="tcl" value="<?php echo $tcl; ?>"> <?php } } ?> </form> Quote Link to comment https://forums.phpfreaks.com/topic/212278-passing-a-value-from-one-form-to-anotherneed-help/#findComment-1106167 Share on other sites More sharing options...
fortnox007 Posted September 1, 2010 Share Posted September 1, 2010 You could also use sessions if you do not want the client to be able to change the hidden fields. But for non relevant info hidden fields work nice Quote Link to comment https://forums.phpfreaks.com/topic/212278-passing-a-value-from-one-form-to-anotherneed-help/#findComment-1106189 Share on other sites More sharing options...
esandra Posted September 2, 2010 Author Share Posted September 2, 2010 thank you, moving my form as you've illustrated solved my problem Quote Link to comment https://forums.phpfreaks.com/topic/212278-passing-a-value-from-one-form-to-anotherneed-help/#findComment-1106248 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.