multi checkbox choice

Discussion in 'PHP' started by mero2020, Feb 20, 2013.

  1. #1
    Hi

    I have form like this at attachment , the problem i want to choose two or more choise for each book
    for example(book1--> economy and law)

    type of books from database table ,and books at another table
    i want to have these results

    1---->law-Engineering
    2---->law-Engineering-Economy
     

    Attached Files:

    mero2020, Feb 20, 2013 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,898
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #2
    We'd need to know how you are storing the book info in the database (or is that part of the question) and how you want to store the results.

    It's pretty simple to get php to generate the html you require, whats harder is to make it usable by the people who have to process what gets entered.
     
    sarahk, Feb 21, 2013 IP
  3. mero2020

    mero2020 Greenhorn

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    13
    #3
    database tables structure

    table(books)
    book_num|book_name|book_type
    ---------------------------
    1 |bookno1 |
    2 |bookno2 |
    3 |bookno3 |

    table(booktype)


    num|type_name
    ---------------------------
    1 |Engineering
    2 |law
    3 |Economy


     
        <?
        $sql= "SELECT * ".
          "FROM books";
     
        $result=mysql_query($sql);?>
        <form name="myform" method="post" action="">
            <table>
            <tr>
            <td >no</td>
            <td >books</td>
        <?$sql= "SELECT * ".
          "FROM booktype"
          ;
        $result=mysql_query($sql);
        while($row=mysql_fetch_array($result))
        {?><td><? echo ' '.$row['type_name'].' '; }?></td>   
            </tr>
            <?
        while($row=mysql_fetch_array($result))
        {
     
     
        ?> <tr>
                    <td><? echo $row[book_num]; ?></td>
            <td><? echo $row[book_name]; ?></td>
     
        <? $sqlt= "SELECT * ".
          "FROM booktype";
     
        $resultt=mysql_query($sqlt);
        while($rowt=mysql_fetch_array($resultt)){
        $tname=    $rowt[type_name];
      ?>
                       
        <td><input type="checkbox" name="typename[]" value=""></td><?}?>
                           
                </tr>
            <?} ?>
        <tr>
                           
                            </tr>
            </table><input type="submit" value="save" id="save" name="save"></form>
    PHP:
    I want to save the results in this way


    book_num|book_name|book_type
    ---------------------------
    1 |bookno1 |law,Economy
    2 |bookno2 |Engineering
    3 |bookno3 |law,Economy,Engineering
     
    mero2020, Feb 23, 2013 IP