Re: multiple selects into mysql database

From: Date: Thu, 24 Aug 2000 18:25:01 +0000
Subject: Re: multiple selects into mysql database
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-13485@lists.php.net to get a copy of this message
At 01:59 PM 8/24/2000 -0400, dbarber wrote:
##### The insert into SQL (the insert works except for $discipline[$z] for($z=0; $z<count($discipline); $z++) echo $discipline; $insquery = "insert into position(id,title,salary,discipline,sector,description ,location) values ('$a','$b','$c','$discipline[$z]','$e','$f','$g') "; $insresult = mysql_query($insquery, $dbLink);
Hi again Dan, Well, I believe your include() call right after the select box works, so I'm expecting that to pass me some variables. Anyway, this code above is echo'ing $discipline, and since that variable is actually an array, it should print out "Array" on your browser. In any case, you shouldn't be echo'ing it, because you need the value of $displine[$z] inside the loop to make the insert sql queries.
for($z=0; $z<count($discipline); $z++) echo $discipline;
All this is doing is looping thru all the array keys, and echoing it, and after you close your "for" loop, you do the sql query. This way, you are only going to insert once. Try this : for ($z = 0; $z < count($discipline); $z++) { $insquery = "INSERT INTO position "; $insquery .= "(id, title, salary, discipline, sector, description, location) "; $insquery .= "VALUES ('$a', '$b', '$c', '$discipline[$z]', '$e', '$f', '$g')"; $insresult = mysql_query($insquery, $dbLink); } Regards, Joao -- Joao Prado Maia Web Developer Kefta.com, Inc

« previous php.general (#13485) next »