PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
dprasad
Forum Newbie
Posts: 6 Joined: Fri Mar 04, 2005 10:31 am
Post
by dprasad » Fri Mar 25, 2005 8:54 am
I want to append multiple selections from a multi select to a database field. The problem is that only the first selection gets appended to the db. The problem is that the array($findkwresult[$no]
only gets set to the first value, any subsquent iterations dont have any values loaded into them:
Code: Select all
while (OCIFetchInto ($s1, $row, OCI_ASSOC)) {
$findkwresult = array();
$findkwresult[] = $row['KEYWORDID'];
}
$selecttype = $_POST['selecttype'];
if(isset($_POST['keywordparam'])){
for($no=0;$no<count($_POST['keywordparam']);$no++){
$keywordelement = $_POST['keywordparam'][$no];
echo 'findkwresult' . $findkwresult[$no];
echo 'keywordelement' . $keywordelement;
//$updateq = "update k3gisdcp.keywords set keyword = keyword || '" . $keywordelement . "' where keyword_id = '" . $findkwresult ."'" ;
$updateq = "update k3gisdcp.keywords set keyword = keyword || 'keyword: " . $keywordelement . "' where keyword_id = '{$findkwresult[$no]}'";
$s2 = OCIParse($c1, $updateq) or die("update error : $updateq");
OCIExecute($s2);
$committed2 = ocicommit($c1);
feyd | Please review how to post code using Code: Select all
tags. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Mar 25, 2005 9:08 am
what type is this database field?
dprasad
Forum Newbie
Posts: 6 Joined: Fri Mar 04, 2005 10:31 am
Post
by dprasad » Fri Mar 25, 2005 9:16 am
its an oracle varchar2
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Mar 25, 2005 9:32 am
not fully up on Oracle syntax versus other sql, but...
Code: Select all
$updateq = 'update k3gisdcp.keywords set keyword = CONCAT(keyword,\' || ' . $keywordelement . '\') where keyword_id = \'' . $findkwresultї$no] . '\'';
Although I'd
implode() the array first, so it only takes 1 query to update the field.