Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. PHP & MySQL

PHP & MySQL

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
phpdatabasemysqlhelpquestion
5 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    Xekria
    wrote on last edited by
    #1

    Hi guys! I need your help ! I'm doing a form in PHP and a want to display in my dropdownlist name column from my DB and save the name_id of that name selected from dropdownlist in DB. Here is my code

    if(isset($_POST["submit"]))
    {
    $bookshop_id = mysql_real_escape_string($_POST["bookshop_id"]);
    $book_id = mysql_real_escape_string($_POST["book_id"]);
    $quantity = mysql_real_escape_string($_POST["quantity"]);

    mysql_query("INSERT INTO `books_bookshop`(`bookshop_id`,`book_id`,`quantity`)
    VALUES ('" . $bookshop_id . "','" . $book_id . "','" . $quantity . "')")
    or die ("Book could not be registered.");

    }

    ?>

    Bookshop Name

    X L M 3 Replies Last reply
    0
    • X Xekria

      Hi guys! I need your help ! I'm doing a form in PHP and a want to display in my dropdownlist name column from my DB and save the name_id of that name selected from dropdownlist in DB. Here is my code

      if(isset($_POST["submit"]))
      {
      $bookshop_id = mysql_real_escape_string($_POST["bookshop_id"]);
      $book_id = mysql_real_escape_string($_POST["book_id"]);
      $quantity = mysql_real_escape_string($_POST["quantity"]);

      mysql_query("INSERT INTO `books_bookshop`(`bookshop_id`,`book_id`,`quantity`)
      VALUES ('" . $bookshop_id . "','" . $book_id . "','" . $quantity . "')")
      or die ("Book could not be registered.");

      }

      ?>

      Bookshop Name

      X Offline
      X Offline
      Xekria
      wrote on last edited by
      #2

      <form method="post" action="#">
      <label for="bookshop_id">Bookshop Name</label>
      <select style="width:148px;" id="bookshop_id" name="bookshop_id" value="bookshop_id" >

      X 1 Reply Last reply
      0
      • X Xekria

        <form method="post" action="#">
        <label for="bookshop_id">Bookshop Name</label>
        <select style="width:148px;" id="bookshop_id" name="bookshop_id" value="bookshop_id" >

        X Offline
        X Offline
        Xekria
        wrote on last edited by
        #3

        <option>
        </option>
        </select>

        <select name="book" id="book" value="book">
        <option></option>
        </select>

        <input type"submit" name="submit" value="Register book">

        </form>

        1 Reply Last reply
        0
        • X Xekria

          Hi guys! I need your help ! I'm doing a form in PHP and a want to display in my dropdownlist name column from my DB and save the name_id of that name selected from dropdownlist in DB. Here is my code

          if(isset($_POST["submit"]))
          {
          $bookshop_id = mysql_real_escape_string($_POST["bookshop_id"]);
          $book_id = mysql_real_escape_string($_POST["book_id"]);
          $quantity = mysql_real_escape_string($_POST["quantity"]);

          mysql_query("INSERT INTO `books_bookshop`(`bookshop_id`,`book_id`,`quantity`)
          VALUES ('" . $bookshop_id . "','" . $book_id . "','" . $quantity . "')")
          or die ("Book could not be registered.");

          }

          ?>

          Bookshop Name

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Why have you posted three messages? It looks like you have answered your own question. Use the Edit link at the bottom of your original, add the extra code and description, and delete the other two messages.

          1 Reply Last reply
          0
          • X Xekria

            Hi guys! I need your help ! I'm doing a form in PHP and a want to display in my dropdownlist name column from my DB and save the name_id of that name selected from dropdownlist in DB. Here is my code

            if(isset($_POST["submit"]))
            {
            $bookshop_id = mysql_real_escape_string($_POST["bookshop_id"]);
            $book_id = mysql_real_escape_string($_POST["book_id"]);
            $quantity = mysql_real_escape_string($_POST["quantity"]);

            mysql_query("INSERT INTO `books_bookshop`(`bookshop_id`,`book_id`,`quantity`)
            VALUES ('" . $bookshop_id . "','" . $book_id . "','" . $quantity . "')")
            or die ("Book could not be registered.");

            }

            ?>

            Bookshop Name

            M Offline
            M Offline
            mrjay42
            wrote on last edited by
            #5

            You know that mysql_ is deprecated for long, right ? "Warning This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include: mysqli_query() PDO::query() " Source http://php.net/manual/en/function.mysql-query.php[^]

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups