vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   INSERT multi-row at once? (https://vborg.vbsupport.ru/showthread.php?t=189578)

mokujin 08-30-2008 07:30 PM

INSERT multi-row at once?
 
Hi,
I need a script, which I can INSERT more rows at once.

I have this code in admincp:

PHP Code:

if ($_REQUEST['do'] == 'add')
     {
     
print_form_header('myscript''insert');
    
print_table_header('Total 10 rows will be shown ');
    
print_select_row('Select a Category''categoryid'fetch_categories_array($catid));
            
    for (
$x 1$x <= 10$x++)
    {
    
print_input_row('Title '.$x.'''title['.$x.']');
    
print_input_row('Description '.$x.'''description['.$x.']');
    }
            
    
print_submit_row($vbphrase['add']);
      } 

How do I have POST insert code?

Can anyone help me?
Thank you (sorry for my very bad English :( )

Dismounted 08-31-2008 05:39 AM

What's POST insert code?

Opserty 08-31-2008 08:48 AM

<a href="http://www.desilva.biz/mysql/insert.html" target="_blank">http://www.desilva.biz/mysql/insert.html</a>

mokujin 08-31-2008 07:03 PM

Quote:

Originally Posted by Dismounted (Post 1610987)
What's POST insert code?

PHP Code:

print_form_header('myscript''insert'); 

You can see: $_POST['do'] = 'insert' in myscript.php here

Quote:

Originally Posted by Opserty (Post 1611040)

Thank you very much, but do you know how to use Loops for multi VALUES?
I mean how to use Loops =>

VALUES
('Helen', 24),
('Katrina', 21),
('Samia', 22),
('Hui Ling', 25),
('Yumie', 29)";


Thank you for helping me :) I hope you understand it

MoT3rror 09-01-2008 05:41 AM

PHP Code:

$sqlvalues 'VALUES';
$first true;

for()
//something goes there or make it a while, foreach
{
$sqlvalues .= ($first '' ', ') . "('" $db->escape_string($somevalue) . "', '" $db->escape_string($somevalue2) . "')";

$first false;
}

$db->query_write("
INSERT INTO TABLE(value1, value2)
$sqlvalues
"
); 


mokujin 09-02-2008 07:38 PM

Thanks MoT3, could you help me again with

$vbulletin->input->clean_gpc('p', 'title', TYPE_STR);
$vbulletin->input->clean_gpc('p', 'description', TYPE_STR);

Now I have method POST = insert like this:

PHP Code:

            // CHECK FOR TOTAL INPUTS...
            
$vbulletin->input->clean_gpc('p''title'TYPE_FILE);
            
$vbulletin->input->clean_gpc('p''description'TYPE_FILE);
            
            
$totaltitles count($vbulletin->GPC['title']['name']);

            
// INSERT FORM
             
$sqlvalues 'VALUES';
             
$first true;
             for(
$x 1$x <= $totaltitles$x++) //something goes there or make it a while, foreach
             
{
                  
$sqlvalues .= ($first '' ', ') . 
                 
                 ('" 
$db->escape_string($somevalue) . "', '" $db->escape_string($somevalue2) . "')
                 
                 "

                 
                 
$first false;
                }

                
/* query insert */
                
$db->query_write("
                INSERT INTO TABLE(value1, value2)
                
$sqlvalues
                "
); 

But there is an error that cant count how many rows need to insert :((

MoT3rror 09-03-2008 04:48 AM

What is title and description supposed to be a file or plain text?

mokujin 09-03-2008 10:05 AM

Quote:

Originally Posted by MoT3rror (Post 1613335)
What is title and description supposed to be a file or plain text?

Its a plain text only, no files. I need the function which counts how many inputs form.

THanks

Marco van Herwaarden 09-03-2008 11:01 AM

PHP Code:

           $vbulletin->input->clean_gpc('p''title'TYPE_FILE); 

Then you should not use TYPE_FILE but TYPE_STR or TYPE_NOHTML.

mokujin 09-03-2008 07:26 PM

Quote:

Originally Posted by Marco van Herwaarden (Post 1613502)
PHP Code:

           $vbulletin->input->clean_gpc('p''title'TYPE_FILE); 

Then you should not use TYPE_FILE but TYPE_STR or TYPE_NOHTML.

Yeah I changed to TYPE_STR, but how can I count total names of the form fields where is not blank?

And how to make this in vbulletin?
Code:

    for ($x = 1; $x <= 10; $x++)
    {
$_POST["title"][$i] = $vbulletin->input->clean_gpc('p', 'title'[$i], TYPE_STR);
}



All times are GMT. The time now is 09:20 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01267 seconds
  • Memory Usage 1,764KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (6)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete