Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Php help manual fetch?

  1. #11
    Join Date
    Jul 2011
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hi Trac,

    With that code do you mean it doesn't passes data to the database?? I want a line that passes data from the form to the mysql database to the selected checkbox category_name.


    Quote Originally Posted by traq View Post
    if, say, you want the value to be 5, just write it that way:
    PHP Code:
    $input '<label><input type="checkbox" name="5">'.$r['category_name'].'</label>'
    but in doing so, you've lost the association with the original database record.

  2. #12
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    if, on each <input>, you use the category_id as the name, then when the form is submitted you will know which category that checkbox belongs to. But if you use some other value (like name="othername"), then you wouldn't be able to tell.

    Personally, I would build each input like this:
    PHP Code:
    '<label><input type="checkbox" name="category[]" value="'.$r['category_id'].'">'.$r['category_name'].'</label>'
    using the same name (the [] make it an array) for each make it easier to access once the form is submitted.

Bookmarks

Posting Permissions

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