Some help with Multiple Mysql Inserts

Discussion in 'PHP' started by KingW, Oct 13, 2009.

  1. #1
    I am a Beginner at PHP, and Need a little help with this

    I have a script for Inserting Videos into a Mysql Database. Currently all I have is the Tables, Which I have made it so you can chose how many to show.

    What I need help with is, How to create the Mysql INSERT to insert however many they chose to add...

    Here is my code so far... Any help/comments/tips/suggestions are welcome

    
    <table width=90%>
    <tr>
    <th colspan=6>Add New Videos
    </th>
    </tr>
    <tr>
    <td width=60>Anime</td>
    <td width=20>Season</td>
    <td width=20>Episode #</td>
    <td width=150>Episode Name</td>
    <td width=150>Video URL</td>
    <td width=50>Host</td>
    </tr>
    </table>
    <table width=90%>
    <form action= method=post><input type=hidden name=subm value=1>
    <?
    $num = $_GET['nm'];
    if($num=="")
    {
    $num = 2;
    }
    $i = 1;
    while($i<$num){
    ?>
    <tr>
    <td><input size=10 type=text name=AnimeN<? echo"$i";?>></td>
    <td><input size=5 type=text name=SnNumber<? echo"$i";?>></td>
    <td><input size=5 type=text name=EpNumber<? echo"$i";?>></td>
    <td><input size=30 type=text name=EpName<? echo"$i";?>></td>
    <td><input size=30 type=text name=VidURL<? echo"$i";?>></td>
    <td>
    <select name=Host<? echo"$i";?>>
    <option value=Myspace>Myspace</option>
    <option value=MegaVideo>Megavideo</option>
    <option value=Veoh>Veoh</option>
    <option value=clip.vn>clip.vn</option>
    <option value=Other>Other</option>
    <option value=MP4>MP4</option>
    </select></td></tr>
    <?php
    $i++;
    }
    ?>
    <tr><td> <input type=submit class=button value="Add Video"></form></td></tr></tr></table>
    
    Code (markup):
     
    Last edited: Oct 13, 2009
    KingW, Oct 13, 2009 IP
  2. Gungz

    Gungz Peon

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Why don't you use looping and insert the data into MySQL one by one.
    You can loop for as many data inserted by user by using your $num variable.
     
    Gungz, Oct 13, 2009 IP
  3. KingW

    KingW Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #3
    I had planned on doing that... But it wouldn't work.. After reading your reply I went back and tried again and it worked perfectly :p
     
    KingW, Oct 14, 2009 IP