Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Posts
    123
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Increasing counters

    I have the following ouput as part of a POST submit form. There are 3 types of users with own counters and submit button. I use the Username(session) and Line No to increase counter. How do I determine which line number a clicked button is on and how do I pass and access the Line number in $_POST? Counters 2 & 3 are also links to files containing name of users who clicked a certain button. In order to display the links(counters), I need identify the appropriate cell containing the counter by Line number and counter number. Should I id each counter like so id='".$LineNo."'Column' or is there a better way of going about this?
    PHP Code:
    echo "<tr><td >".$LineNo."</td><td>".$Text."</td><td>Counter1</td><td>button1</td><td>Counter2</td><td>button2</td><td>Counter3</td><td><button3</td></tr>"
    Hope this isn't too vague.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    You can't search an id for a selected line number. PHP is server side only, you need to send the line number back with a request in order to tell PHP about it. It hasn't a clue what you are talking about in regards to HTML (you cannot specify a relative location or respond to an onclick event).
    You can tell which submit button was selected by providing them with unique names (or arrays should work I'd suspect since you can only provide it with one successful input value). That can then be used to determine which button was clicked (maybe that is on its own line), and you can go from there.

  • #3
    Regular Coder
    Join Date
    Apr 2007
    Posts
    123
    Thanks
    1
    Thanked 0 Times in 0 Posts
    When one of the buttons is clicked I can get the user type using the session username. I then check the the appropriate button with
    PHP Code:
    if(isset($_POST['ButtonName'])) 
    I can then get the LineNo (first cell in row) using
    Code:
    reset(array_keys($_POST['ButtonName']))
    The counter cell id is 'CellName{$row['LineNo']}'
    I have created a txt file and a counter as a link to the file
    PHP Code:
    $Link "<a href='path/to/txt/file.txt'>{$counter}</a>"
    Now what I want to do is insert the link, $Link into the counter cell. How do I go about this?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •