Jump to content

passing a value from one form to another:need help


esandra

Recommended Posts

//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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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