insert 5 records at a time in mysql database

Discussion in 'PHP' started by s4salman, Aug 20, 2007.

  1. #1
    Hello
    i use this code to add record into database:

    <form action="insert-bsongs.php" method="post">
    Application Name: <input type="text" name="name" size="60"/>
    <BR>
    Details: <input type="text" name="details" size="60"/>
    <br>
    song 1: <input type="text" name="song1" size="60"/>
    <br>
    URL 1: <input type="text" name="url1" size="60"/>
    
    <input type="Submit"/>
    </form>
    HTML:
    <?
    
    $db="v2073_test";
    $Name=$_POST['name'];
    $Details =$_POST['details'];
    $Song1=$_POST['song1'];
    
    $Url1=$_POST['url1'];
    
    
    mysql_connect("localhost","USER","PASSWORD") or die(mysql_error());
    @mysql_select_db($db) or die( "Unable to select database, Please contact your administrator");
    $query = ("INSERT INTO bsongs (`id` , `name` , `details` , `song1` , `url1`)"); 
    mysql_query($query) or die(mysql_error());
    mysql_close();
    ?>
    PHP:
    but now what i want to change html and php code, so that at a time i can add 5 records.
    plz help
     
    s4salman, Aug 20, 2007 IP
  2. jakomo

    jakomo Well-Known Member

    Messages:
    4,262
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    138
    #2
    Hello,
    if you want to save the same information.. You should add in your PHP code a loop :)

    best,
    Jakomo
     
    jakomo, Aug 20, 2007 IP
  3. Wildhoney

    Wildhoney Active Member

    Messages:
    192
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #3
    
    INSERT INTO
    	myTable
    	(myColumn1, myColumn2)
    VALUES
    	('Col 1, Row 1', 'Col 1, Row 2')
    	('Col 2, Row 1', 'Col 2, Row 2')
    
    Code (markup):
    Like so.
     
    Wildhoney, Aug 20, 2007 IP