This topic is locked

multiline lookup + inserts

11/6/2007 4:32:09 PM
PHPRunner General questions
C
ccuser author

I have a multiline lookup wizard that I want the user to be able to select more than one option (from a key field) using the shift key.

PHPRunner allows this but only inserts one of the selected option/key column values.
Is there any way for it to insert multiple times for each of the values chosen?
I'm sure there must be a way to do this using the BeforeAdd event but I haven't been able to find a way to retrieve every selected option

from the multiline lookup wizard.
Thanks for your help!

J
Jane 11/7/2007

Hi,
yuo can't use multiline option for lookup wizard if link and display fields are different.
As workaround you can do the following:

  1. add new field to your table in the database where all values will be stored.
  2. check off this field on the list an view pages only on the Choose fields tab.
  3. add Before record added and Before record updated events on the Events tab.

    Here is a sample:
    global $conn;

    $linkvalues = explode(",",$values["FieldName"]);

    for ($i=0; $i<count($linkvalues); $i++)

    {

    $str = "select DisplayField from LookupTableName where LinkField=".$linkvalues[$i];

    $rs = db_query($str,$conn);

    if ($data = db_fetch_array($rs))

    $displayvalues[$i] = $data["DisplayField"];

    }

    $values["NewFieldName"] = implode(",",$displayvalues);

    return true;



where NewFieldName is your created field.

B
barbary 2/14/2008

Dears,

I used the code, but I always get error.

I have table named "outage" with field named "pop"

"pop" is the field I use to be multiline.

"pop" is line with "pop-id". The value written to table is "pop-id".

I created a new field "tx".

can you please tell me how to adjust the code to be suitable for me???

It is really important to me and I really appreciate your cooperation.

J
Jane 2/15/2008

Hi,
to say what's happening I need the original error message.

B
barbary 2/15/2008

Dear,

here is my code:

global $conn;

$linkvalues = explode(",",$values["pop"]);

for ($i=0; $i<count($linkvalues); $i++)

{

$str = "select pop from _outage where pop-id=".$linkvalues[$i];

$rs = db_query($str,$conn);

if ($data = db_fetch_array($rs))

$displayvalues[$i] = $data["pop"];

}

$values["tx"] = implode(",",$displayvalues);

return true;


and here is the error message:

Error type 256

Error description: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

URL: localhost/irs4/_outage_add.php?

Error file: E:\www\vhosts\localhost\irs4\include\dbconnection.php

Error line: 26

SQL query: insert into `_outage`

Solution: This is a general error. It occurs when there is an error in event code or in SQL.
Send your SQL or event code along with full error message tosupport@xlinesoft.com.


_outage is the table name

pop is the multiline field

pop-id is the link field

tx is the new field
Thanks and BR,

J
Jane 2/15/2008

Hi,
it's difficult to tell you what's happening without seeing actual files.
You can please publish your project on Demo Account and post a URL to your pages here or send it to [email=support@xlinesoft.com]support@xlinesoft.com[/email] along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.