This topic is locked

Multi Record

2/14/2008 12:41:15 PM
PHPRunner General questions
B
barbary author

Dears

I made a multi select field,

It gives me all the values in one record, I want to separate each value in a record, meaning that when selecting 8 values from (POP_ field) to add 8 records in the database with all the rest values.

how can I do that ?? <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=7565&image=1&table=forumtopics' class='bbc_emoticon' alt=':(' />
BR,

Mahmoud

J
Jane 2/15/2008

Mahmoud,
use Before record added event on the Events tab for this purpose.

Here is a sample:

global $conn;

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

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

{

$str = "insert into TableName (FieldName) values (".$arr[$i].")";

db_exec($conn);

}



where FieldName is your actual field names.

B
barbary author 2/15/2008

Dears,
I used the following code and it gave me an error

global $conn;

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

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

{

$str = "insert into _outage (pop) values (".$arr[$i].")";

db_exec($conn);

}


and this is the error message:

Missing argument 2 for db_exec(), called in E:\www\vhosts\localhost\irs4\include\_outage_events.php on line 94 and defined

SQL query: insert into `_outage`


Thanks and BR,

Mahmoud

J
Jane 2/15/2008

Mahmoud,
sorry for my fault.

Here is the correct code:

global $conn;

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

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

{

$str = "insert into _outage (pop) values (".$arr[$i].")";

db_exec($str,$conn);

}

B
barbary author 2/15/2008

Dear,

I really appreciate your fast response.

I got this error code :

Error type: 256

Error description: Column count doesn't match value count at row 1


Can you tell me what to do ??
Thanks and BR,

Mahmoud

J
Jane 2/15/2008

Mahmoud,
to debug your code print SQL query on teh page before executing:

...

$str = "insert into _outage (pop) values (".$arr[$i].")";

echo $str;

...


Then execute printed query in the database and correct it in the code.

B
barbary author 2/15/2008

Thanks again,

but I didn't get what you mean ... I printed the code in the page and then do what ??!!

forgive me, I'm just a newbie.


Thanks and BR,

Mahmoud

B
barbary author 2/17/2008

Der Admins,

Isn't there a sloution??
thanks,

Mahmoud

J
Jane 2/18/2008

Mahmoud,
try to use this code:

global $conn;

if ($values["pop"])

{

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

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

{

$str = "insert into _outage (pop) values (".$arr[$i].")";

db_exec($str,$conn);

}

}

B
barbary author 2/18/2008

Dears,

Still giving the same result, 1 record containing all values.

there is a note the maybe useful, the field "POP" is linked with another field "POP-ID" in another table.
Thanks and BR,

J
Jane 2/18/2008

Hi,
please publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error and your order number.

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