SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wink how to insert more than one value

    how to insert into one table multiple values
    i mean i have a joke database and i want some of my users add more than one joke by clicking submit button
    this jokes will go to its own category
    Last edited by ohm; Mar 5, 2002 at 06:53.

  2. #2
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should do this with a while() function...

    the princepal is

    while there are jokes
    upload joke to blablabla
    end of while


    Now the script will carry out the upload once at a time and enough times so all the data is uploaded .

    Greets

    Peanuts
    the neigbours (free) WIFI makes it just a little more fun

  3. #3
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy i think i asked the wrong question..

    i have to admit that i am just a beginner and i think i did not asked the question properly i dont know how to do this while loop
    i have got following code and i want to change it to add more than one joke i have one submit button i tried to put second one but it sends the record which i pressed i want to call some values by select function i know how to do it i created a relational database but i want to add more than one record by clicking button such as in bla bla catagories i ll add ten jokes i will have ten form and i ll enter values and just by one click i ll be the happiest man in the world here is the code

    <?php
    if (isset($addjoke)): // If the user wants to add a joke
    ?>
    <form action="<?=$PHP_SELF?>" method="post">
    <p>Type your joke herebr />
    <textarea name="joketext" rows="10" cols="40" wrap></textarea><br />
    <input type="submit" name="submitjoke" value="SUBMIT" /></p>
    </form>
    <?php

    and here is the adding part

    // If a joke has been submitted,
    // add it to the database.
    if ($submitjoke == "SUBMIT") {
    $sql = "INSERT INTO Jokes SET
    JokeText='$joketext',
    JokeDate=CURDATE()";
    if (@mysql_query($sql)) {
    echo("<p>Your joke has been added.</p>");
    } else {
    echo("<p>Error adding submitted joke: " .
    mysql_error() . "</p>");
    }
    }
    if you think i have to send all php file i can send it 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
  •