Making multiple rows with one query
         
               Posted on 
16th Feb 2014 07:03 pm by  
admin
        
        I have a table called efed_handler_characters with two fields handler_id and bio_id. What query 2 is supposed to do is get the id from the handler and then with each char(acter) is supposed to make a new record for each of them with that same handler id. I"m trying to figure out how this is done?
Code: <?php
case 1:
         echo $e;
            require_once('../backstageconfig.php');
         require_once('../backstagefunctions.php');
         ?>
            <h1 class="backstage">Handler Management</h1><br />
            <h2 class="backstage">Add New Handler Account</h2><br />
            <form name="addnewhandler" method="post">
                <input type="hidden" name="action" value="handler" />
                <table width="100%" class="table2">
                    <tr>
                        <td width="120" class="rowheading">Username:</td><td class="row3"><input type="text" name="login" class="fieldtext490"></td>
                    </tr>
                    <tr>
                        <td class="rowheading">Password:</td><td class="row3"><input type="password" name="password" class="fieldtext490"></td>
                    </tr>
                    <tr>
                        <td class="rowheading">Surname:</td><td class="row3">
                        <input type="text" name="surname" class="fieldtext490"></td>
                    </tr>
                    <tr>
                        <td class="rowheading">Firstname:</td>
                        <td class="row3"><input type="text" name="firstname" class="fieldtext490"></td>
                    </tr>
                    <tr>
                        <td class="rowheading">Email:</td>
                        <td class="row3"><input type="text" name="email" class="fieldtext490"></td>
                    </tr>
                    <tr>
                        <td class="rowheading">AIM:</td>
                        <td class="row3"><input type="text" name="aim" class="fieldtext490"></td>
                    </tr>
                    <tr>
                        <td class="rowheading">MSN:</td>
                        <td class="row3"><input type="text" name="msn" class="fieldtext490"></td>
                    </tr>
                    <tr>
                        <td class="rowheading">Forum ID:</td>
                        <td class="row3"><input type="text" name="forumid" class="fieldtext490"></td>
                    </tr>
                    <tr>
                        <td class="rowheading">Account:</td><td class="row3">
                        <select name="enabled" class="selection">
                        <option value="0">- Select -</option>
                        <?php
                        $query = 'SELECT name,id FROM efed_list_status';
                        $result = mysql_query ( $query );
                        while ( $row = mysql_fetch_assoc ( $result ) ) 
                        {
                            print "<option value="".$row['id']."">".$row['name']."</option>r";
                        }
                        ?>
                        </select></td>
                    </tr>
                    <tr>
                        <td class="rowheading">Administrator:</td><td class="row3">
                        <select name="isadmin" class="selection">
                        <option value="0">- Select -</option>
                        <option value="2">No</option><option value="1">Yes</option>
                        </select></td>
                    </tr>
                </table><br />
                <input type="hidden" name="newadded" value="true">
                <input type="submit" value="Save Handler" class="button" name="submit"></form><br />
                <input type="submit" value="Return to Handler List" class="button200"><br /><br />
                <h2 class="backstage">Characters<br /><br /><form method="post"><select name="characterid" id="characterid" class="dropdown">
                <option value="0">- Select -</option>
                <?php
                $query = 'SELECT charactername FROM efed_bio';
                $result = mysql_query ( $query );
                while ( $row = mysql_fetch_assoc ( $result ) ) 
                {
                print "<option value="".$row['charactername']."">".$row['charactername']."</option>r";
                }
                ?>
                </select>  <input type="hidden" id="chars" name="chars" value=""><input type="button" value="Add" class="button" onclick="WrestlerList()"></form></h2><br />
                <ul id="characterlist"></ul><br />
            <script type="text/javascript" language="javascript"> 
            function WrestlerList()
            {
            var addWrestler = document.addwrestler.characterid.value;
            if (addWrestler) {
            document.getElementById("chars").value += addWrestler+",";
            document.getElementById("characterlist").innerHTML += "<li>" + 
            addWrestler + "</li>";
            return WrestlerList;
            }
            else {
            document.getElementById("characterlist").innerHTML += "<li>This handler does not have any characters assigned.</li>";
            }
            }
         </script>
            </form>
            <?php
            returnmain();
        break;
}
   function handler() {
      if ((!empty($_POST['newadded']))) {
         $password = md5($password);
            $login = mysql_real_escape_string($_POST['login']);
            $p = mysql_real_escape_string($_POST['password']);
            $surname = mysql_real_escape_string($_POST['surname']);
            $firstname = mysql_real_escape_string($_POST['firstname']);
            $email = mysql_real_escape_string($_POST['email']);
            $aim = mysql_real_escape_string($_POST['aim']);
            $msn = mysql_real_escape_string($_POST['msn']);
            $forumid = mysql_real_escape_string($_POST['forumid']);
            $isadmin = mysql_real_escape_string($_POST['isadmin']);
            $enabled = mysql_real_escape_string($_POST['enabled']);
         $char_array = explode(",", $_POST['chars']); 
         $query1 = "INSERT INTO `efed_handler` (surname,firstname,isadmin,login,password,enabled,aim,msn,forumid,email,fed_id,) VALUES ('".$surname."','".$firstname."','".$isadmin."','".$login."','".$password."','".$enabled."','".$aim."','".$msn."','".$forumid."','".$email."',1)";
         mysql_query($query);
         $query1_id = mysql_insert_id(); 
         $query2 = "INSERT INTO `efed_handler_characters` (handler_id, bio_id) VALUES (".$query1_id.", $char_array)";
            mysql_query($query2);           
      }
   }
?>       
      
       
		No comments posted yet	
	Your Answer:
	        Login to answer
        
120  
 27 
 
    
    
 
Other forums
Two warning messages 
Quote<b>Warning</b>:  mysql_real_escape_string() expects parameter 1 to 
validating url 
im trying to validate url's sent to me by a form
the url's im collecting are for placing banners 
CURL XML Request [From C to PHP] 
Hi,  
I need some help converting this into something that will work with PHP.
Code: #
Credit card verification 
I have a client who wants to process credit card transactions from his web site rather than the goin
php not working written for consumption of slots 
1. Here is the function where i will be allowed to consume the slot booked by me.
2. Here i c
CE 7.1 and External GIS integration 
Hi All,
We want to develop an application on CE 7.1 which uses GIS features from an exter
Extending Exception to contain method name 
I was wondering, if there's a way to extend Exception in such a way, that it would contain name of a
Writing Windows Device Drivers with C 
Yes: one of the nice features of C is void*.  You can put anything there and get anything out.  Very
[function.file]: failed to open stream: No such file or directory 
Okay I wrote this little script to upload a csv file that is located on my webhosts server to a mysq
my sql select id and then update problem. 
I need to select some auto incremented ids out of a database and then use those id in a where statem