Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 08-30-2008, 07:30 PM
mokujin's Avatar
mokujin mokujin is offline
 
Join Date: Oct 2005
Location: Czech
Posts: 345
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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 )
Reply With Quote
  #2  
Old 08-31-2008, 05:39 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What's POST insert code?
Reply With Quote
  #3  
Old 08-31-2008, 08:48 AM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<a href="http://www.desilva.biz/mysql/insert.html" target="_blank">http://www.desilva.biz/mysql/insert.html</a>
Reply With Quote
  #4  
Old 08-31-2008, 07:03 PM
mokujin's Avatar
mokujin mokujin is offline
 
Join Date: Oct 2005
Location: Czech
Posts: 345
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dismounted View Post
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 View Post
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
Reply With Quote
  #5  
Old 09-01-2008, 05:41 AM
MoT3rror MoT3rror is offline
 
Join Date: Mar 2007
Posts: 423
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
"
); 
Reply With Quote
  #6  
Old 09-02-2008, 07:38 PM
mokujin's Avatar
mokujin mokujin is offline
 
Join Date: Oct 2005
Location: Czech
Posts: 345
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 (
Reply With Quote
  #7  
Old 09-03-2008, 04:48 AM
MoT3rror MoT3rror is offline
 
Join Date: Mar 2007
Posts: 423
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What is title and description supposed to be a file or plain text?
Reply With Quote
  #8  
Old 09-03-2008, 10:05 AM
mokujin's Avatar
mokujin mokujin is offline
 
Join Date: Oct 2005
Location: Czech
Posts: 345
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MoT3rror View Post
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
Reply With Quote
  #9  
Old 09-03-2008, 11:01 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
           $vbulletin->input->clean_gpc('p''title'TYPE_FILE); 
Then you should not use TYPE_FILE but TYPE_STR or TYPE_NOHTML.
Reply With Quote
  #10  
Old 09-03-2008, 07:26 PM
mokujin's Avatar
mokujin mokujin is offline
 
Join Date: Oct 2005
Location: Czech
Posts: 345
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Marco van Herwaarden View Post
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);
}
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:22 AM.


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.06089 seconds
  • Memory Usage 2,284KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (6)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete