Author Topic: how to retain buttons after clicking  (Read 669 times)

0 Members and 1 Guest are viewing this topic.

Offline esandraTopic starter

  • Irregular
  • Posts: 37
    • View Profile
how to retain buttons after clicking
« on: September 01, 2010, 10:40:00 PM »
//my program generates this button ($tcl) more than one times and then when i click it all the ($tcl) buttons would //disappear. what ive been trying to do here is when i click one of the $tcl buttons, they would remain visible until i choose //another date. how do i do this?
<table height="100%" width="70%">
   <tr><form name="date" method="post">
//this part gets the date
        <td align="left">SELECT : <select name="date" id="date">
           <?php
         $query="select distinct date from arrastre order by date desc";
         $result=mysql_query($query);
         while($row=mysql_fetch_array($result)){
               $date=$row['date'];   
         echo "<option value='".$date."'>$date</option>";
         }
         ?>
            </select> 
//this the part that the $tcl buttons are created using $date from above as reference
          <input name="godate" type="submit" value="go"></form>   <br><br><br>
   </tr>   
   <tr>
        <td align="left">TCL:
        <?php
      if(isset($_POST['godate'])){
         $date=$_POST['date'];
         $query="select distinct tcl from arrastre where date='$date' order by tcl asc";
         $result=mysql_query($query);
         echo '<form method="POST"><input type="hidden" name="date" value="'. $date. '">';
         while($row=mysql_fetch_array($result)){
            $tcl=$row['tcl'];
            ?>
            <input type="submit" name="tcl" value="<?php echo $tcl; ?>">     //this is the button generated more than  one time depending on how many $tcl there on that date
            <?php } }
            ?>
            </form>
    </tr>
//this part takes the $tcl and $date to display the values from the database
   <?php
      if((isset($_POST['tcl'])) && (isset($_POST['date']))){   
         $tcl=$_POST['tcl'];
         $date=$_POST['date'];
         $query = "select * from `arrastre` where `tcl` = '" . $tcl. "' and `date` = '" . $date . "' order by `tcl` asc";
         $result = mysql_query($query) or die(mysql_error());
         
         while($row=mysql_fetch_array($result)){
            $orno=$row['orno'];
            $billnmbr=$row['billnmbr'];
            $payor=$row['payor'];
            $arrastre=$row['arrastre'];
            $wharfage=$row['wharfage'];
            $total=$row['total'];
            $date=$row['date'];                  
               }
   ?>
   <tr>///display part erased to shorten
    </tr>
    <?php }$_POST['tcl']=1;
   }
      
   ?>
    <tr>
       <td colspan="3">
       <td colspan="2">total collections:
        <td align="right"><?php echo $totformat;?>
    </tr>
</table>
//my only problem here is that when i click a $tcl button and after it displays the form, all of the $tcl buttons would //disappear but i want them to still be there until i choose another date, only then should it display another set of $tcl //buttons
//thank you for your time  :shy:

Offline RussellReal

  • Addict
  • Posts: 1,730
  • Gender: Male
    • View Profile
Re: how to retain buttons after clicking
« Reply #1 on: September 02, 2010, 02:02:33 AM »
I'd love to help you.. but you made like no sense :) also use
Code: [Select]
tags please :)
Like my help and want to hire me? Email me or add me to MSN at RussellonMSN@hotmail.com

Offline esandraTopic starter

  • Irregular
  • Posts: 37
    • View Profile
Re: how to retain buttons after clicking
« Reply #2 on: September 02, 2010, 03:56:03 AM »
yea i know this picture is hard to understand..but i really need help so ill try again
1. i get distinct $date from database then put the values into a combo box
    user can choose a date by selecting date from combo box then click go button
2.  there may be more than 1 values of $tcl in one date so when i click a date which has more than one $tcl on it, there would be more than one $tcl buttons, one for every $tcl from that date

my problem is that whenever i click a $tcl button all of the buttons would disappear. what i want to happen here is for the buttons to remain where they are so i could choose another $tcl from that date without going back to the date combo box again and again.

so i want to choose date once and be able to click tcl lots of times from that date
thanks

Offline RussellReal

  • Addict
  • Posts: 1,730
  • Gender: Male
    • View Profile
Re: how to retain buttons after clicking
« Reply #3 on: September 02, 2010, 06:33:21 AM »
try adding hidden fields to each form you create called 'godate' that will allow your first php block to execute :)
Like my help and want to hire me? Email me or add me to MSN at RussellonMSN@hotmail.com

Offline fortnox007

  • Devotee
  • Posts: 777
  • Gender: Female
  • mooOO
    • View Profile
Re: how to retain buttons after clicking
« Reply #4 on: September 02, 2010, 08:09:29 PM »
If you want immidiate action without reloading the page you need javascript or ajax which is almost the same but it sounds cooler.
"Give a monkey a banana and you feed him for a day; teach a monkey to rob banks and he will feed you for a lifetime."
http://www.addedbytes.com/writing-secure-php/writing-secure-php-1/
<br />
error_reporting(E_ALL);
ini_set("display_errors", 1);

Offline esandraTopic starter

  • Irregular
  • Posts: 37
    • View Profile
Re: how to retain buttons after clicking
« Reply #5 on: September 02, 2010, 11:14:48 PM »
try adding hidden fields to each form you create called 'godate' that will allow your first php block to execute :)
wow one line did it..thanks

Offline RussellReal

  • Addict
  • Posts: 1,730
  • Gender: Male
    • View Profile
Re: how to retain buttons after clicking
« Reply #6 on: September 03, 2010, 01:02:30 AM »
no doubt :) mark as solved :D THANKS!
Like my help and want to hire me? Email me or add me to MSN at RussellonMSN@hotmail.com