Forums

Save Data under particular column name

PowerOfChronoform 28 Jul, 2012
Hello sir,

I have a chronoform form linked to the menu item . after form is submitted . I would like to save/store the few of the form data field to the 2 specific column of the table . the column names of the destination table and the filed names of the chronoform form is completely different . So , is it possible sir to store/save data under specific column name of different table (non chronoform table) through chronoform form settings or custom php code . here I trying to store the few form data to the columns names of the K2 extension/component table .

Thank you.
GreyHead 28 Jul, 2012
Hi PowerOfChronoform,

Yes, you can do that. The simplest way is to change the names of the inputs in your form to match the column names in the table. If you can't do that then you can use a Custom Code action to make a copy of the form result with a different name:
<?php
$form->data['column_name'] =$form->data['input_name'];
?>
Either of those approaches will let you use the ChronoForms DB Save action with a 'normal' table.

My recollection is that K2 uses a more complicated table structure and, if so, you may need to hand-code the DB query to save the data.

Bob
PowerOfChronoform 28 Jul, 2012
Thank you.

Please find the attachment.

I did like this but data is not inserting into the table under column "arttitle" . chronoform saves the data to the table jlh7i_chronoforms_data_addart and also custom code saves the data to the same table jlh7i_chronoforms_data_addart but for one column of the table that is "arttitle" and this custom code operation is before chronofrom db operation .

here is my code in "custom code "

Mode : controller .
<?php

$arttitle = mysql_real_escape_string($form->data['arttitle']);
echo $arttitle ;

$db =& JFactory::getDBO();
$q = "INSERT INTO jlh7i_chronoforms_data_addart SET arttitle=$arttitle ";
$db->setQuery($q);



?> 
GreyHead 28 Jul, 2012
Hi PowerOfChronoform ,

You probably need quotes '' round $arttitle and you've left out the line that actually runs the query $db->query();

Bob
PowerOfChronoform 28 Jul, 2012
Sir, sorry.

it worked fine in this way -
$q = "INSERT INTO jlh7i_k2_items SET title ='".$arttitle."' ";
$qw= mysql_query($q) ;

but not working when we add second parameter to insert .

like this

$q = "INSERT INTO jlh7i_k2_items SET title ='".$arttitle."' , fulltext ='".$fulltext."' ";
$qw= mysql_query($q) ;

Sir,Do we need to use chronoform framework libraries for this ?


Hi PowerOfChronoform ,

You probably need quotes '' round $arttitle and you've left out the line that actually runs the query $db->query();

Bob

PowerOfChronoform 28 Jul, 2012
and also I came to know that , my first filed in form is arttitle (name) and second field in the form is fulltext (name).

it works only works and insert the data when we only used the first field of the form that is artiltle in the query but when we used all all other form fields in the query . it does not work and will insert the data into the table , no increment of row.

Please help .

Thank you.
GreyHead 29 Jul, 2012
Hi PowerOfChronoform,

The MySQL looks OK - you haven't given enough information for me to say anything else.

Where is $fulltext defined?

Bob
PowerOfChronoform 29 Jul, 2012
Sir, Sorry.

The table is of k2 extension named - jlh7i_k2_items . the column name fulltext is present in the k2 table .

I executed sql query through phpmyadmin where also it not able to insert into the fulltext field , so k2 is NOT allowing to insert into the fulltext field through phpmyadmin or through extrenally . fulltext only able get insert through k2 item submission form and when we used "read more break" in the item article. When we not use "read more break" in article item the fulltext field is not inserted(feeds up) .

through chronoform form and other externally I'm able to insert data to any column of the k2 table except fulltext .

I wonder how they restricting it to insert data to that column .

now, I using extra filed options instead of fulltext .

Thank you very much.
GreyHead 29 Jul, 2012
Hi PowerOfChronoform,

Try using introtext instead.

Bob
PowerOfChronoform 07 Aug, 2012
Thank you sir.

I used the "extra field" and used introtext field for another main data insert.

Thank you sir.
This topic is locked and no more replies can be posted.