Subject:*
<
Name/Email:*
<
Message Icon:*
<
Select*
<
Message:*
<



Click the Preview to see the content in action.
Options:*
<
Confirmation Code*
<
3 + 3 = ?  
Input the result from the expression
Maximum attempts you can try: 10
*
<
     
0) { $datas = array(); for( $i = 0; $i $table_mid[$i], 'field_tid' => $table_id[$i], 'field_numb' => $table_nbfields[$i], 'field_name' => $_POST['field_name'][$i], 'field_type' => $_POST['field_type'][$i], 'field_value' => $_POST['field_value'][$i], 'field_attribute' => $_POST['field_attribute'][$i], 'field_null' => $_POST['field_null'][$i], 'field_default' => $_POST['field_default'][$i], 'field_key' => $_POST['field_key'][$i], 'field_autoincrement' => (($_REQUEST['field_autoincrement'][$i] == 1) ? '1' : '0'), 'field_element' => $_POST['field_element'][$i], 'field_inlist' => (($_REQUEST['field_inlist'][$i] == 1) ? '1' : '0'), 'field_inform' => (($_REQUEST['field_inform'][$i] == 1) ? '1' : '0'), 'field_admin' => (($_REQUEST['field_admin'][$i] == 1) ? '1' : '0'), 'field_user' => (($_REQUEST['field_user'][$i] == 1) ? '1' : '0'), 'field_block' => (($_REQUEST['field_block'][$i] == 1) ? '1' : '0'), 'field_main' => (($i == $_REQUEST['field_main']) ? '1' : '0'), 'field_search' => (($_REQUEST['field_search'][$i] == 1) ? '1' : '0'), 'field_required' => (($_REQUEST['field_required'][$i] == 1) ? '1' : '0') ); } foreach ($datas as $value) { $obj->setVars( $value ); $fieldsHandler->insert($obj); } }[/code] so this: [code]if ($table_nbfields > 0) [/code] will never be true and you will never get to the code that you have shown us. And of course, you will never be able to test any changes you are making to it. You define the variable as: [code]$table_nbfields = TDMCreate_CleanVars($_REQUEST, 'table_nbfields');[/code] But there is no variable of this name in the $_REQUEST. There is the "field_numb", which seems to be the one that you're should be using. Fix that, and then you'll be able to see if the whole array issue is working or not. Always check your logic to make sure that you are getting what you expect to get, and that's why tools like [url=http://phpunit.de/][b]PHPUnit [/b][/url]are so helpful :-)[/quote]" />

Re: Inserting multiple rows in database table
by timgno on 2014/5/2 11:48:05

For this reason, I have now created a tutorial that explains how you can do it in a very simple way, a script, which through a simple form, send the data to the mysql database mode multirows with php
Re: Inserting multiple rows in database table
by timgno on 2014/5/1 22:45:20

Even if none of you has been technically help, I'm glad I shared the idea with you

It helped me to understand that I had to go back to the basis of the studies php.

In fact, rebuilding all the work behind it, with mysql, php and a simple form, I created a mini, mini, mini, cms, "please let me get through these words" , I was able to rebuild all the code necessary and is enough to cancel rather than add another code.

Great, is it?

Thanks anyway for having contributed to the idea at least.
Re: Inserting multiple rows in database table
by redheadedrod on 2014/5/1 22:21:31

Cool. Great that it worked for you. I wasn't sure if you could pass an array like that to setVars or not.

Hope my input helped you progress.

Only wish I could have been more help.

Rodney
Re: Inserting multiple rows in database table
by timgno on 2014/5/1 17:50:02

It was very simple

It was enough to remove the foreach loop, and instead use an array datas with setVars(), used directly the setVar() function for each variable, and checks on the same variables with isset

View the file in svn
Re: Inserting multiple rows in database table
by timgno on 2014/4/24 18:16:18

It's true what you say about security.

In any case, the module in question works only locally, at least from what I see and I do.

This module would have no meaning for the time to install it on a remote server.

In a local server you can make any changes you want.

I Sending files, that mentioned earlier, in svn

if you want to take a look at the code.

Who's Online

234 user(s) are online (207 user(s) are browsing Support Forums)


Members: 0


Guests: 234


more...

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits