How do I use $wpdb->insert
to insert multiple rows. Here is my code.
for($i=0; $i<=$urlCount; $i++) {
$stat = $wpdb->insert(
'WP_URLS',
array(
'POSTID' => $post->ID,
'URL' => $_POST['url'.$i]
)
);
}
This code works only for the first insert (ie, when $i = 0
, when value is url_0
). Sometimes the URL count will be more than 100 and sometimes it will be zero. So instead of writing the code for 100 times, I just want to have a simple loop that works for any number of records. Thats the reason I went for loop.
Thank you for the help.
The table structure is
CREATE TABLE WP_URLS (
POSTID BIGINT NOT NULL,
URL VARCHAR(254)
);