Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6792209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:56:29+00:00 2026-05-26T17:56:29+00:00

I have simple form: <form action=add.php method=post > <input name=name maxlength=30/><br/> <textarea cols=80 name=description

  • 0

I have simple form:

   <form action="add.php" method="post" >
        <input  name="name"  maxlength="30"/><br/>
        <textarea  cols="80" name="description" rows="10">
        </textarea><br/>

        <table>
            <thead>
                   <tr>
                       <th></th>
                       <th width="200px">Shop list</th>
                   </tr>
            </thead>
             <tbody div class ="table">
            <?php
            $result = mysql_query("SELECT shop_id, name FROM shop") or die(mysql_error());
            if(mysql_num_rows($result) > 0) {
                while($row = mysql_fetch_assoc($result)) {
                echo '<tr> 
                         <td>
                         <input type="checkbox" name="identifer[]" value="'.$row['shop_id'].'" /> <br /></td>  
                         <td>'.ucfirst($row['shop']).'</td> 
                      </tr>   ';    
                                                         }
                                            }
                  ?>

    </tbody></table>
<input type="submit" value="Add">
</form>

I want to save the results in database in two different tables: book (book_id, name, description) and places. In places table I want to save shops where you can buy that book (places_id, book_id, shop_id).

I have add.php file (it’s not working):

    <?php
    $name = $_POST['name'];
    $description = $_POST['description'];



        $identifer =($_POST['identifer']);
        if (isset($identifer)){

            $id_arr = implode(',', $identifer);
            $result = mysql_query("INSERT INTO places (places_id, book_id, shop_id) VALUES (NULL, NULL ($id_arr))") or die(mysql_error());

        }   




$q = "INSERT INTO baldas (book_id, name, description) VALUES (NULL, '$name', '$description')";

$result2 = mysql_query($q) or die(mysql_query());   

    ?>

I’m confused how I have to save results in two different tables in the same time, also I have problems with identifying which checkboxes are checked and to write the results in database, especially I have no idea how to deal with book_id.
Any advice would be helpful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:56:29+00:00Added an answer on May 26, 2026 at 5:56 pm

    I have no idea how to deal with book_id

    You would first insert the values into table baldas, then call mysql_insert_id()

    <?php
      $q = "INSERT INTO baldas (book_id, name, description) VALUES (NULL, '$name', '$description')";
      $result = mysql_query($q) or die(mysql_query());
    
      $bookID = mysql_insert_id();
    
      // CODE TO INSERT INTO `places` TABLE USING $bookID //
    ?>
    

    I have problems with identifying which checkboxes are checked

    The way you have them, you’d have to loop through the $_POST['identifier'] array to identify the shop_id

    <?php
      foreach((array)$_POST['identifier'] as $shopID) { 
          $q2 = "INSERT INTO places (place_id, book_id, shop_id) VALUES (NULL, '$bookID', '$shopID')";    
          $result2 = mysql_query($q2) or die(mysql_error()); 
      }
    ?>
    

    If it’s not checked it won’t show up in the $_POST

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple form. <form target=_blank action=somescript.php method=Post id=simpleForm> <input type=hidden name=url value=http://...> <input
I have a simple form like this: <form name=serachForm method=post action=/home/search> <input type=text name=searchText
I have a simple form: <form id=formTest name=formTest action= method=get> <input id=txtPostcode name=Postcode type=text
On the page 'selecteditems.php' I have a form like this: <form method=POST name=selecteditems action=nextpage.php>
I have this code in my HTML form: <form action=cart.php method=post> <input type=hidden value=1
I have an input form for a sample php. <form action=insert.php method=post> <table> <tr>
I have a simple html form and some php that input the POST variables
I have the following form in cakephp: <div class=quickcontactDisplay> <?php echo $form->create('Enquiry',array('action'=>'add','class'=>'quickcontact')); echo $form->hidden('visitor_id',
I have a simple email address sign up form as follows: <form action= id=newsletterform
I have a simple form with some plain html input like bellow using ASP.NET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.