Line 31 of your PHP code:
- $ind = $cell->getAttribute( 'Index' );
Should be:
-
$ind = $cell->getAttribute( 'ss:Index' );
-
The name of the attribute excel uses to indicate which column a field entry is supposed to occupy is called 'ss:Index', rather than just 'Index'.
-
<?php
-
-
$data = array();
-
include 'ez_sql.php';
-
function import($itemno,$logoid,$colorid,$styleid,$descriptorid,$logoname,$colorname,$stylename,$descriptorname,$itemname)
-
{
-
$q2="select item_number from temp where item_number='$itemno'";
-
$iname=mysql_query($q2);
-
$name=mysql_num_rows($iname);
-
if($name == 0)
-
{
-
-
$q1="insert into temp(id,item_number,logo_id,color_id,style_id,descriptor_id,logo_name,color_name,style_name,descriptor_name,item_name) values('','$itemno','$logoid','$colorid','$styleid','$descriptorid','$logoname','$colorname','$stylename','$descriptorname','$itemname')";
-
mysql_query($q1);
-
}
-
-
}
-
if ( $_FILES['file']['tmp_name'] )
-
{
-
$dom = DOMDocument::load( $_FILES['file']['tmp_name'] );
-
$rows = $dom->getElementsByTagName( 'Row' );
-
$first_row = true;
-
$i = 0;
-
foreach ($rows as $row)
-
{
-
if ( !$first_row )
-
{
-
$itemno = "";
-
$logoid = "";
-
$colorid = "";
-
$styleid = "";
-
$descriptorid = "";
-
$logoname = "";
-
$colorname = "";
-
$stylename = "";
-
$descriptorname = "";
-
$itemname ="";
-
-
$index = 1;
-
$cells = $row->getElementsByTagName( 'Cell' );
-
foreach( $cells as $cell )
-
{
-
if ( $index == 1 )
-
{
-
$itemno = $cell->nodeValue;
-
}
-
if($itemno != '000000000000')
-
{
-
if( $index == 2 )
-
{
-
$logoid = $cell->nodeValue;
-
}
-
if($logoid != '000')
-
{
-
if( $index == 3 )
-
{
-
$colorid = $cell->nodeValue;
-
}
-
if($colorid != '000')
-
{
-
if( $index == 4 )
-
{
-
$styleid = $cell->nodeValue;
-
}
-
if($styleid != '000')
-
{
-
if( $index == 5 )
-
{
-
$descriptorid = $cell->nodeValue;
-
}
-
if( $index == 6 )
-
{
-
$logoname = $cell->nodeValue;
-
}
-
if( $index == 7 )
-
{
-
$colorname = $cell->nodeValue;
-
}
-
if( $index == 8 )
-
{
-
$stylename = $cell->nodeValue;
-
}
-
if( $index == 9 )
-
{
-
$descriptorname = $cell->nodeValue;
-
}
-
if( $index == 10 )
-
{
-
$itemname = $cell->nodeValue;
-
}
-
}
-
else
-
{ exit; }
-
}
-
else
-
{ exit; }
-
}
-
else
-
{ exit; }
-
}
-
else
-
{ exit; }
-
-
$index += 1;
-
}
-
import($itemno,$logoid,$colorid,$styleid,$descriptorid,$logoname,$colorname,$stylename,$descriptorname,$itemname);
-
}$first_row = false;
-
-
}
-
}
-
-
?>
-
this is my page from where i m inserting the data of xml.I want to do that the item no that is already inserted that is not inserted again and if the logoid,colorid,styleid anyone from it is '000' then that record also not inserted.But i have problem with this code is that,suppose i have 5 itemnos,3rd one is duplicate and the forth one has logoid is 000 and fifth one has true data,then in database 3 records only inserted that is 1st,2nd.But 5 record is true but it also not inserted.So in real 1,2,5 records goes in database but i have only 1,2 goes in database.
And my second problem is that,in excel i save the llogoid,colorid,styleid,descriptorid as 001,016,010,010 so it is stored in database as 1,16,10,10.And my itemno is as per this values that is 001016010010 but it is stored as it is.there is no problem with this.
I sent my xml file in next post refer it.
Here is my xml:
<?xml version="1.0"?>
<Worksheet ss:Name="Master Import Sheet">
<Table ss:ExpandedColumnCount="11" ss:ExpandedRowCount="43" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="15">
<Row ss:Height="15.75">
<Cell ss:StyleID="s86"
ss:Formula="=CONCATENATE((TEXT(RC[1],"000")),(TEXT(RC[2],"000")),(TEXT(RC[3],"000")),(TEXT(RC[4],"000")))"><Data
ss:Type="String">001016002001</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">1</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">16</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">2</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">1</Data></Cell>
<Cell ss:StyleID="s87"
ss:Formula="=VLOOKUP(RC[-4],'DesignLogo (ABC)'!C[-5]:C[-4],2,FALSE)"><Data
ss:Type="String">SW-Explorer</Data></Cell>
<Cell ss:Formula="=VLOOKUP(RC[-4],'Color (DEF)'!C[-6]:C[-5],2,FALSE)"><Data
ss:Type="String">Goldenrod</Data></Cell>
<Cell ss:Formula="=VLOOKUP(RC[-4],'StyleUnit (GHI)'!C[-7]:C[-6],2,FALSE)"><Data
ss:Type="String">Ladies Standard T-Shirt</Data></Cell>
<Cell ss:StyleID="s87"
ss:Formula="=VLOOKUP(RC[-4],'Descriptor (JKL)'!C[-8]:C[-7],2,FALSE)"><Data
ss:Type="String">Wholesale Youth XS</Data></Cell>
<Cell ss:StyleID="s82"
ss:Formula="=CONCATENATE(RC[-1]," ",RC[-2]," ",RC[-3]," ",RC[-4])"><Data
ss:Type="String">Wholesale Youth XS Ladies Standard T-Shirt Goldenrod SW-Explorer</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s86"
ss:Formula="=CONCATENATE((TEXT(RC[1],"000")),(TEXT(RC[2],"000")),(TEXT(RC[3],"000")),(TEXT(RC[4],"000")))"><Data
ss:Type="String">004016002001</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">4</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">16</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">2</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">1</Data></Cell>
<Cell ss:StyleID="s87"
ss:Formula="=VLOOKUP(RC[-4],'DesignLogo (ABC)'!C[-5]:C[-4],2,FALSE)"><Data
ss:Type="String">SW-Animal</Data></Cell>
<Cell ss:Formula="=VLOOKUP(RC[-4],'Color (DEF)'!C[-6]:C[-5],2,FALSE)"><Data
ss:Type="String">Goldenrod</Data></Cell>
<Cell ss:Formula="=VLOOKUP(RC[-4],'StyleUnit (GHI)'!C[-7]:C[-6],2,FALSE)"><Data
ss:Type="String">Ladies Standard T-Shirt</Data></Cell>
<Cell ss:StyleID="s87"
ss:Formula="=VLOOKUP(RC[-4],'Descriptor (JKL)'!C[-8]:C[-7],2,FALSE)"><Data
ss:Type="String">Wholesale Youth XS</Data></Cell>
<Cell ss:StyleID="s82"
ss:Formula="=CONCATENATE(RC[-1]," ",RC[-2]," ",RC[-3]," ",RC[-4])"><Data
ss:Type="String">Wholesale Youth XS Ladies Standard T-Shirt Goldenrod SW-Animal</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s86"
ss:Formula="=CONCATENATE((TEXT(RC[1],"000")),(TEXT(RC[2],"000")),(TEXT(RC[3],"000")),(TEXT(RC[4],"000")))"><Data
ss:Type="String">016013002001</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">16</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">13</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">2</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">1</Data></Cell>
<Cell ss:StyleID="s87"
ss:Formula="=VLOOKUP(RC[-4],'DesignLogo (ABC)'!C[-5]:C[-4],2,FALSE)"><Data
ss:Type="String">SW-Butterfly</Data></Cell>
<Cell ss:Formula="=VLOOKUP(RC[-4],'Color (DEF)'!C[-6]:C[-5],2,FALSE)"><Data
ss:Type="String">Crunchberry</Data></Cell>
<Cell ss:Formula="=VLOOKUP(RC[-4],'StyleUnit (GHI)'!C[-7]:C[-6],2,FALSE)"><Data
ss:Type="String">Ladies Standard T-Shirt</Data></Cell>
<Cell ss:StyleID="s87"
ss:Formula="=VLOOKUP(RC[-4],'Descriptor (JKL)'!C[-8]:C[-7],2,FALSE)"><Data
ss:Type="String">Wholesale Youth XS</Data></Cell>
<Cell ss:StyleID="s82"
ss:Formula="=CONCATENATE(RC[-1]," ",RC[-2]," ",RC[-3]," ",RC[-4])"><Data
ss:Type="String">Wholesale Youth XS Ladies Standard T-Shirt Crunchberry SW-Butterfly</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s86"
ss:Formula="=CONCATENATE((TEXT(RC[1],"000")),(TEXT(RC[2],"000")),(TEXT(RC[3],"000")),(TEXT(RC[4],"000")))"><Data
ss:Type="String">016013002001</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">16</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">13</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">2</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">1</Data></Cell>
<Cell ss:StyleID="s87"
ss:Formula="=VLOOKUP(RC[-4],'DesignLogo (ABC)'!C[-5]:C[-4],2,FALSE)"><Data
ss:Type="String">SW-Butterfly</Data></Cell>
<Cell ss:Formula="=VLOOKUP(RC[-4],'Color (DEF)'!C[-6]:C[-5],2,FALSE)"><Data
ss:Type="String">Crunchberry</Data></Cell>
<Cell ss:Formula="=VLOOKUP(RC[-4],'StyleUnit (GHI)'!C[-7]:C[-6],2,FALSE)"><Data
ss:Type="String">Ladies Standard T-Shirt</Data></Cell>
<Cell ss:StyleID="s87"
ss:Formula="=VLOOKUP(RC[-4],'Descriptor (JKL)'!C[-8]:C[-7],2,FALSE)"><Data
ss:Type="String">Wholesale Youth XS</Data></Cell>
<Cell ss:StyleID="s82"
ss:Formula="=CONCATENATE(RC[-1]," ",RC[-2]," ",RC[-3]," ",RC[-4])"><Data
ss:Type="String">Wholesale Youth XS Ladies Standard T-Shirt Crunchberry SW-Butterfly</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s86"
ss:Formula="=CONCATENATE((TEXT(RC[1],"000")),(TEXT(RC[2],"000")),(TEXT(RC[3],"000")),(TEXT(RC[4],"000")))"><Data
ss:Type="String">000001003004</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">0</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">1</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">3</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">4</Data></Cell>
<Cell ss:StyleID="s87"
ss:Formula="=VLOOKUP(RC[-4],'DesignLogo (ABC)'!C[-5]:C[-4],2,FALSE)"><Data
ss:Type="String">Test Logo</Data></Cell>
<Cell ss:Formula="=VLOOKUP(RC[-4],'Color (DEF)'!C[-6]:C[-5],2,FALSE)"><Data
ss:Type="String">Khaki Green</Data></Cell>
<Cell ss:Formula="=VLOOKUP(RC[-4],'StyleUnit (GHI)'!C[-7]:C[-6],2,FALSE)"><Data
ss:Type="String">Unisex Recycled T-Shirt</Data></Cell>
<Cell ss:StyleID="s87"
ss:Formula="=VLOOKUP(RC[-4],'Descriptor (JKL)'!C[-8]:C[-7],2,FALSE)"><Data
ss:Type="String">Wholesale Youth L</Data></Cell>
<Cell ss:StyleID="s82"
ss:Formula="=CONCATENATE(RC[-1]," ",RC[-2]," ",RC[-3]," ",RC[-4])"><Data
ss:Type="String">Wholesale Youth L Unisex Recycled T-Shirt Khaki Green Test Logo</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s86"
ss:Formula="=CONCATENATE((TEXT(RC[1],"000")),(TEXT(RC[2],"000")),(TEXT(RC[3],"000")),(TEXT(RC[4],"000")))"><Data
ss:Type="String">005007002003</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">5</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">7</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">2</Data></Cell>
<Cell ss:StyleID="s91"><Data ss:Type="Number">3</Data></Cell>
<Cell ss:StyleID="s87"
ss:Formula="=VLOOKUP(RC[-4],'DesignLogo (ABC)'!C[-5]:C[-4],2,FALSE)"><Data
ss:Type="String">SW-Security</Data></Cell>
<Cell ss:Formula="=VLOOKUP(RC[-4],'Color (DEF)'!C[-6]:C[-5],2,FALSE)"><Data
ss:Type="String">Bay</Data></Cell>
<Cell ss:Formula="=VLOOKUP(RC[-4],'StyleUnit (GHI)'!C[-7]:C[-6],2,FALSE)"><Data
ss:Type="String">Ladies Standard T-Shirt</Data></Cell>
<Cell ss:StyleID="s87"
ss:Formula="=VLOOKUP(RC[-4],'Descriptor (JKL)'!C[-8]:C[-7],2,FALSE)"><Data
ss:Type="String">Wholesale Youth M</Data></Cell>
<Cell ss:StyleID="s82"
ss:Formula="=CONCATENATE(RC[-1]," ",RC[-2]," ",RC[-3]," ",RC[-4])"><Data
ss:Type="String">Wholesale Youth M Ladies Standard T-Shirt Bay SW-Security</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s86"
ss:Formula="=CONCATENATE((TEXT(RC[1],"000")),(TEXT(RC[2],"000")),(TEXT(RC[3],"000")),(TEXT(RC[4],"000")))"><Data
ss:Type="String">000000000000</Data></Cell>
<Cell ss:StyleID="s91"/>
<Cell ss:StyleID="s91"/>
<Cell ss:StyleID="s91"/>
<Cell ss:StyleID="s91"/>
<Cell ss:StyleID="s87"
ss:Formula="=VLOOKUP(RC[-4],'DesignLogo (ABC)'!C[-5]:C[-4],2,FALSE)"><Data
ss:Type="String">Test Logo</Data></Cell>
<Cell ss:Formula="=VLOOKUP(RC[-4],'Color (DEF)'!C[-6]:C[-5],2,FALSE)"><Data
ss:Type="String">Custom Choice</Data></Cell>
<Cell ss:Formula="=VLOOKUP(RC[-4],'StyleUnit (GHI)'!C[-7]:C[-6],2,FALSE)"><Data
ss:Type="String">Test Style</Data></Cell>
<Cell ss:StyleID="s87"
ss:Formula="=VLOOKUP(RC[-4],'Descriptor (JKL)'!C[-8]:C[-7],2,FALSE)"><Data
ss:Type="String">Null Descriptor</Data></Cell>
<Cell ss:StyleID="s82"
ss:Formula="=CONCATENATE(RC[-1]," ",RC[-2]," ",RC[-3]," ",RC[-4])"><Data
ss:Type="String">Null Descriptor Test Style Custom Choice Test Logo</Data></Cell>
</Row>
</Workbook>
Please help me........
thanks............