473,387 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to insert array generated by Preg_match_all in database

Expand|Select|Wrap|Line Numbers
  1. mysql_query("CREATE TABLE $value (Subject VARCHAR(200), External int(3))");
  2.         preg_match_all('/<i>(.*?)<\/i>/si', $matches[0], $submatch, PREG_SET_ORDER);
  3.         mysql_query("INSERT INTO $value (Subject) VALUES ('$submatch[2][1]')");    
its only a part of the code
$matches[0] contains html data with tags
i'm matching the data between the <i> and </i> tags
and i guess its been stored in $submatch array

now i want to knw a way through which i can insert each match into a different row using mysql query

i tried running two foreach loops and tried inserting like this
Expand|Select|Wrap|Line Numbers
  1. foreach ($submatch as $tempone) {
  2.  
  3.                 foreach ($tempone as $key=>$temptwo) 
  4.             {
  5.                 mysql_query("INSERT INTO $value (Subject) VALUES ('$temptwo')");    
  6.         }
  7.      }
but whats happening is the array $submatch contains the pattern with the tags and also without tags
that is for each match there are two array positions like
$submatch[0][0] contains <i>xysdbhdg</i> and
$submatch[0][1] contains xysdbhdg


and both are getting inserted... i wanna insert oly ones which are like $submatch[0][1] contains xysdbhdg i mean ones without the tags :)
Sep 30 '10 #1
1 1745
no one knwos the solution??
Oct 1 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: EMiller | last post by:
Hello, I am encountering a development challenge here that seems to be stumping me. I am developing a C#/.NET application using an MSDE database. There is a particular field in a table that I...
1
by: garimapuri | last post by:
hi ihad an array in php and iwant to insert its value in database the coding is: <?php $nv_pairs = explode('&',$query_string); $array; list ($name, $value) = explode ('=',$nv_pairs); $i = 0;...
5
by: Rick Spiewak | last post by:
I need to generate a "buy" button as part of an ASP.NET page - this consists of a small HTML form with hidden fields, conforming to the requirements of a merchant credit card processor. PayPal is...
4
by: chambersdon | last post by:
I have an application that needs to insert nulls into the database and I don't seem to be able to do this. I am currently trying to do this with a Typed DataSet but I can't seem to Insert Nulls...
0
by: danishce | last post by:
Hello, I want to insert data directly into my windows form data grid and load a combobox(userid) in the 1st column of data grid,a textbox(password) in 2nd column of datagrid. The code for insert...
7
by: sanjeevcis | last post by:
Hi, Below code is regarding to insert an array values into mysql db using php. i dont know why the code is not inserting array values into database properly. If is there any thing wrong with the...
1
by: Zuggy | last post by:
I'm trying to create a registration/login script using Access 2003. I'm using ADOdb to connect through ODBC. <?php // Connects to your Database include('adodb/adodb.inc.php'); # load code...
8
by: Betikci Boris | last post by:
Can not insert data into SQLite3 database through browser however i can easily insert data into my db from konsole, in both attmpts i used php 5.2.6 on 2.6.25.* linux kernel i think there is a...
0
by: akshalika | last post by:
I am new to Biztalk. In my project we need to connect oracle database and insert data into oracle table using BizTalk project. I use WCF Adapter pack(SP2). I create biztalk project then using Consume...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.