SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2004
    Location
    ireland
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sending multiple copies to database

    Hi,
    I am trying to send multiple copies of information on a form to a mysql database using a quantity field on the form, each copy having a different id.

    if(!$title)
    {?>

    <form Name=addStock METHOD="post">
    <p> Title: <input type="text" name="title"> </p>
    <p> Year: <input type="text" name="releaseYear"> </p>
    <p> Quantity: <input type="text" name="a"> </p>
    <button type="submit" >ADD</button>
    </form>

    <?
    }
    else
    {
    $query = "INSERT INTO test(title, releaseYear) VALUES ('$title', '$releaseYear')";
    echo"<p>$title has been added to your database</p>";
    $result = mysql_query($query);

    }
    ?>

    I have tried putting for and while loops around the query but no luck it either loops infinitely or doesnt work. Any ideas?? Thanks

  2. #2
    Non-Member hyperimage's Avatar
    Join Date
    Dec 2003
    Location
    Croatia
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    your form is completely wrong!!!
    u have to use $_POST attribute to insert to mysql function!
    HTML Code:
    <form Name="addStock" METHOD="post">
    Title:<input type="text" name="title"><br>
    Year: <input type="text" name="releaseYear"><br>
    Quantity: <input type="text" name="a"><br>
    <input type="submit" name="update" value"ADD">
    </form>
    PHP Code:
    <?php
    if(isset($_POST["update"])) insert_data();
    function 
    insert_data()
    {
    if(
    $title!="")
    {
    $ret"INSERT INTO test VALUES('', '$title', '$releaseYear')"
    echo
    "$title has been added to your database<br>\n";
    $resultat mysql_query($ret);

    }
    ?>
    but u have to explain better what multiple data u want to insert into database!
    cya


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
  •