Update Button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • matthewroth
    New Member
    • Feb 2008
    • 22

    Update Button

    A little help from the gurus.
    I have this script that shows fields from 1 table. I want to add a button that will automatically change Status field from Open to Closed[php]<?
    include_once("./sql_connect.php ");
    // Get Title of documents
    $getdceventSql = "SELECT Id, Event, Remedy, Status, SubmittedBy FROM dc_event WHERE Status = 'Open'";
    $getdceventResu lt = mysql_query($ge tdceventSql);
    $content = $content. "<br />\n";
    while (list($Id, $Event, $Remedy, $Status, $SubmittedBy) = mysql_fetch_row ($getdceventRes ult))
    {
    $content = $content.
    "Id: $Id</a> <br />\n";
    $content = $content.
    "Event: $Event</a> <br />\n";
    $content = $content.
    "Ticket #: $Remedy</a> <br />\n";
    $content = $content.
    "Current Status: $Status</a> <br />\n";
    $content = $content.
    "Submitted By: $SubmittedBy</a> <br />\n";
    }
    echo "<div id='content'>"
    .$content
    ."</div>";
    ?>[/php]any help of clues would be appreciated
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    You'd just make a form with a button and then submit the form.

    Using POST check if the button was pressed and then update your mysql table.

    Simple :)

    Comment

    • matthewroth
      New Member
      • Feb 2008
      • 22

      #3
      my concern is having a Close button after each entry

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by matthewroth
        my concern is having a Close button after each entry
        Echo a form with a submit button on it after each entry then.

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          at the end of your content build you append the button.[php]
          $content .= "Submitted By: $SubmittedBy</a>";
          $content .= "<form method='POST' action='".$_SER VER['PHP_SELF']."'>".
          "<input type='submit' name='submit' value='Close entry'>".
          "<input type='hidden' name='closebutt on' value='$Id'>".
          "</form> <br />\n";[/php]
          When the Close button is hit, the routine will be invoked passing the ID to be closed in POST array with key 'closebutton', so you have to catch that by specifying, at the start of your script, the following:[php]
          if (isset($_POST['closebutton'])) {
          $idtobeclosed=s trip_tags($_POS T['closebutton']);
          //
          // close the MySQL row with the id number in $idtobeclosed
          //
          }[/php]Ronald

          Comment

          Working...