Selecting Table row records for editing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • webhigh

    Selecting Table row records for editing

    I¹m not sure if this a PHP question or an MySQL question but here it goes.

    I have a repeat region of a table called userid

    What I¹m trying to accomplish is being able to edit the record and then
    update it by clicking a submit button on the same line. I¹m doing it this
    way so the user can quickly update a number of records one at a time. I know
    I could do this by passing the userid info to a detail page but really want
    to do it the way described. My problem is how do you select and then update
    a specific row record ?

    Thanks in advance.

  • Kevin Thorpe

    #2
    Re: Selecting Table row records for editing

    webhigh wrote:[color=blue]
    > I’m not sure if this a PHP question or an MySQL question but here it goes.
    >
    > I have a repeat region of a table called userid
    >
    > What I’m trying to accomplish is being able to edit the record and then
    > update it by clicking a submit button on the same line. I’m doing it
    > this way so the user can quickly update a number of records one at a
    > time. I know I could do this by passing the userid info to a detail page
    > but really want to do it the way described. My problem is how do you
    > select and then update a specific row record ?[/color]

    I do 'inline' editing in quite a few of my scripts. It often makes
    things easier. The way to do that is as follows:

    foreach ($userrecords as $userid => $userrecord) {
    if ($userid == $_REQUEST['currentid']) {
    # output the edit form for this record
    } else {
    # output a display row for this record
    # ensure there is a link to $PHP_SELF?curre ntid=$userid
    }
    }

    Then your initial display will be a page listing all your user records.
    Click on the select link and you will get the same page with the chosen
    record in a form for amendment. The form submit will then save your
    changes and go back to the list. You can fiddle with currentid to select
    the next record if you wish.

    Comment

    • Chung Leong

      #3
      Re: Selecting Table row records for editing

      Selecting Table row records for editing
      "webhigh" <webhigh@attbi. com> wrote in message
      news:BCAA8580.1 285A%webhigh@at tbi.com...
      I'm not sure if this a PHP question or an MySQL question but here it goes.

      I have a repeat region of a table called userid

      What I'm trying to accomplish is being able to edit the record and then
      update it by clicking a submit button on the same line. I'm doing it this
      way so the user can quickly update a number of records one at a time. I know
      I could do this by passing the userid info to a detail page but really want
      to do it the way described. My problem is how do you select and then update
      a specific row record ?

      ----------------------------------------

      What you can do is give each record a separate form, each with its submit
      button. Say the records are listed in a table...

      <table>
      <tr>
      <form action="save_re cord.php" method="post">
      <td><input type ="text" name="name"></td>
      ...
      <td><input type="hidden" name="userid" value="42">
      <input type="submit" value="Save"></td>
      </td>
      </form>
      </tr>

      Save_record.php would changes to that record. Now here's the trick: if no
      error was encountered, the script returns the HTTP status code 204 ("No
      Content"). The browser's response to this is to keep the current page. No
      refresh happens so you user doesn't lose the place s/he's at.


      Comment

      • Tony Marston

        #4
        Re: Selecting Table row records for editing

        Selecting Table row records for editingIn my humble opinion your approach is all wrong. You should not allow updates on a list/browse form. Instead you should allow the user to select one or more entries on the current screen then press an UPDATE button which will go into a detail screen with its own SUBMIT button. If more than one record was selected you should display links which allow the user to step forwards and backwards through the selected items.

        If you visit http://www.tonymarston.net/php-mysql...plication.html this will give you access to an online demonstration. You can then download the code and run it locally.

        HTH

        --
        Tony Marston

        This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL



        "webhigh" <webhigh@attbi. com> wrote in message news:BCAA8580.1 285A%webhigh@at tbi.com...
        I'm not sure if this a PHP question or an MySQL question but here it goes.

        I have a repeat region of a table called userid

        What I'm trying to accomplish is being able to edit the record and then update it by clicking a submit button on the same line. I'm doing it this way so the user can quickly update a number of records one at a time. I know I could do this by passing the userid info to a detail page but really want to do it the way described. My problem is how do you select and then update a specific row record ?

        Thanks in advance.

        Comment

        • webhigh

          #5
          Re: Selecting Table row records for editing

          On 4/21/04 6:37 AM, in article c65isk$lou$1$83 00dec7@news.dem on.co.uk, "Tony
          Marston" <tony@NOSPAM.de mon.co.uk> wrote:
          [color=blue]
          > In my humble opinion your approach is all wrong. You should not allow updates
          > on a list/browse form. Instead you should allow the user to select one or more
          > entries on the current screen then press an UPDATE button which will go into a
          > detail screen with its own SUBMIT button. If more than one record was selected
          > you should display links which allow the user to step forwards and backwards
          > through the selected items.
          >
          > If you visit http://www.tonymarston.net/php-mysql...plication.html this
          > will give you access to an online demonstration. You can then download the
          > code and run it locally.
          >
          > HTH[/color]

          Thanks ­ It looks great would love to have something like this but I down
          loaded the code and it is way beyond me. Which I could just upload and
          select the table and the fields to show.

          I kept getting the following:
          This application has encountered an unrecoverable error

          The following has been reported to the administrator:

          2004-04-21 08:33:19

          Fatal Error: MySQL error: 1044 : Access denied for user: 'value@localhos t'
          to database 'sample' (# 256).

          Error in line 173 of file
          '/home/value/public_html/phpapps/sample/std.dml.class.i nc'.

          Script: '/phpapps/sample/person_list.php '.

          Object/Class: 'dml', Parent Class: ''.

          Remote Address: (I deleted)

          Warning: error_log(/home/value/public_html/errorlog.html): failed to open
          stream: Permission denied in
          /home/value/public_html/phpapps/sample/error.inc on line 88


          Comment

          Working...