SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    May 2011
    Posts
    242
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Creating a new table with only checked checkboxed

    Good day,

    I have a webpage where two tables are showed, with a checkbox in each row for being selected or not.
    Here an extract of the code, where tables are created based on values from a database.

    Body of table 1:

    while($row = mysql_fetch_row($result)) {
    echo "<tr ALIGN=CENTER VALIGN=TOP>";
    for($column_num = 0; $column_num < $column_count; $column_num++) {
    echo "<td>$row[$column_num]</td>\n";
    }
    echo '<td><input type="checkbox" name="check[]" value="$row"></td>';
    echo "</tr>\n";
    }


    Body of table 2:

    while($row = mysql_fetch_row($result_new)) {
    echo "<tr ALIGN=CENTER VALIGN=TOP>";
    for($column_num = 0; $column_num < $column_count; $column_num++) {
    echo "<td>$row[$column_num]</td>\n";
    }
    echo '<td><input type="checkbox" name="check_op[]" value="$row"></td>';
    echo "</tr>\n";
    }


    When the page is in use, people has to select some rows (checkboxes) from table 1 and table 2.
    After finish, a "Next" button is selected, and a new webpage is opened, where I'd like to have one single table showing only selected rows from table 1 and table 2 (and no more checkboxes).

    Could you please let me k now how to do it?

    Thanks a lot!!!

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,508
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    As the value of the checkboxes, use the key that identifies the row in the database.
    In the receiving php script, retrieve those rows from the database (with a WHERE keycolumn IN (value1, value2, ecc) ) and show the data.

  3. #3
    SitePoint Addict
    Join Date
    May 2011
    Posts
    242
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi Guido,

    Once again, thanks a lot.

    Could you please explain me this a little more, hopefully with an example?
    I guess I couldnt understand you properly.

    Thanks!!


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
  •