George L.
|
| Posted: 07/18/2002, 7:19 PM |
|
Here's a function i build to help me insert values from a muliple SELECT listbox.
Maybe it will help someone out there.<br><br>
Just be careful. This function was written with support for oracle. You may have to modify it slightly or add another argument to the function for the first value in the values section of the insert statement.<br>
(Just change admindstdb_id_sq . "." . nextval with whatever PK sequencer that use)<br><br>
Function will follow...
|
|
|
 |
George L.
|
| Posted: 07/18/2002, 7:28 PM |
|
function
insertFromMultiList($param_name,$table,$assignto_col,$assignfrom_col,$list_c
ol,$assignfrom_val)
{<br><br>
/*<br>
gpl - Custom DSET Function.<br>
Function used with multiple select listboxes. It<br>
will gather all of the selected values from the<br>
the multiple select form. It will then insert selected values<br>
into the designted table.<br><br>
Arg1: $param_name = Name given to the SELECT Input Box.<br>
Arg2: $table = The database assignment table to insert values into.<br>
Arg3: $assignto_col = Assignment column tht represents the PK of the assignment table.<br>
Arg4: $assignfrom_col = Column that represents the PK of the originating table.<br>
Arg5: $list_col = Column that represents the PK of the table containing the list values.<br>
Arg6: $assignfrom_val = Actual value that will be used to insert into $assignfrom_col column.<br>
(This must be assigned from an outside method; e.g. a SELECT statment .)<br><br>
Usage:<br>
Number of arguments: 6<br><br>
Number of built-in PHP functions: N/A<br><br>
*/<br><br>
//Initialize connection class <br>
$db_listgrp = new clsDBDD_DEV();<br><br>
global $HTTP_POST_VARS;<br>
global $HTTP_GET_VARS;<br>
$Where = "";<br><br>
if (isset($HTTP_GET_VARS[$param_name])){<br>
$array_p = $HTTP_GET_VARS[$param_name];<br>
}<br>
if (isset($HTTP_POST_VARS[$param_name])){<br>
$array_p = $HTTP_POST_VARS[$param_name];<br>
}<br>
//$size_p = count($array_p);<br>
if ($array_p){<br>
//print_r($array_p);//Debug<br><br>
foreach ($array_p as $value){<br>
//Initialize query attributes.<br>
$sSQLx = "insert into $table (" .<br>
"$assignto_col," . <br>
"$assignfrom_col," . <br>
"$list_col)" . <br>
" values (" . <br>
admindstdb_id_sq . "." . nextval . "," .<br>
CCToSQL($assignfrom_val, "Number") . "," . <br>
$value . <br>
")";<br><br>
//Execute baby!<br>
$db_listgrp->query($sSQLx);<br>
}<br>
}<br>
return;<br>
}<br><br>
Hope that helps someone.<br>
email mex909gman@netscape.net if you have any specific questions on usage.
|
|
|
 |
George L.
|
| Posted: 07/18/2002, 7:37 PM |
|
Lets try this again
function
insertFromMultiList($param_name,$table,$assignto_col,$assignfrom_col,$list_c
ol,$assignfrom_val)
{
/*
gpl - Custom DSET Function.
Function used with multiple select listboxes. It
will gather all of the selected values from the
the multiple select form. It will then insert selected values
into the
designted table.
Arg1: $param_name = Name given to the SELECT Input
Box.
Arg2: $table = The database assignment table to
insert values into.
Arg3: $assignto_col = Assignment column tht
represents the PK of the assignment table.
Arg4: $assignfrom_col = Column that represents the
PK of the originating table.
Arg5: $list_col = Column that represents the PK of
the table containing the list values.
Arg6: $assignfrom_val = Actual value that will be
used to insert into $assignfrom_col column.
(This must be assigned from an outside method; e.g.
a SELECT statment .)
Usage:
Number of arguments: 6
Number of built-in PHP functions: N/A
*/
//Initialize connection class
$db_listgrp = new clsDBDD_DEV();
global $HTTP_POST_VARS;
global $HTTP_GET_VARS;
$Where = "";
if (isset($HTTP_GET_VARS[$param_name])){
$array_p = $HTTP_GET_VARS[$param_name];
}
if (isset($HTTP_POST_VARS[$param_name])){
$array_p = $HTTP_POST_VARS[$param_name];
}
//$size_p = count($array_p);
if ($array_p){
//print_r($array_p);//Debug
foreach ($array_p as $value){
//Initialize query attributes.
$sSQLx = "insert into $table (" .
"$assignto_col," .
"$assignfrom_col," .
"$list_col)" .
" values (" .
admindstdb_id_sq . "." . nextval . "," .
CCToSQL($assignfrom_val, "Number") . "," .
$value .
")";
//Execute baby!
$db_listgrp->query($sSQLx);
}
}
return;
}
|
|
|
 |
|