PHP Processing Industry Classification data

Source: Internet
Author: User

Implementation steps:

1. Save the Excel table as a file with the suffix. csv format;

2. Import the. csv format file into the MySQL database;

3. Identify and import the required data into another data table through a conditional query;

Here are some of the PHP fragments:

<?PHPmysql_connect("localhost", "root", "root") or die("Could Not Connect:".)Mysql_error()); mysql_select_db("Test"); mysql_query("SET NAMES ' UTF8 '"); $result=mysql_query("Select Col2, Col5, col6 from category where col2!= '"); Echo"INSERT into ' qy_category ' (' catid ', ' moduleid ', ' catname ', ' catdir ', ' linkurl ', ' parentid ', ' arrparentid ', ' child ', ' Arrchildid ', ' listorder ', ' seo_title ', ' seo_keywords ', ' seo_description ') VALUES ";  while($row=Mysql_fetch_array($result,Mysql_assoc)) {        //printf ("ID:%s Name:%s", $row ["col2"], $row ["COL5"]); echo "<br/>";        $result 2=mysql_query("Select Col3, Col5, col6 from the category where Col3 like '".$row["Col2"]. " %‘"); $arr=Array();  while($row 2=Mysql_fetch_array($result 2,Mysql_assoc)) {            if($row 2["Col6"]== ")$row 2["Col6"]=$row 2["Col5"]; printf('%s ', 4, '%s ', '%s ', ' list.php?catid=%s ', '%s ', '%s ', 0, '%s ', '%s ', '%s ', '%s ', '%s '),$row 2["Col3"],$row 2["Col5"],$row 2["Col3"],$row 2["Col3"],$row["col2"], ' 0, '.$row["col2"]. ', '.$row 2["Col3"],$row 2["Col3"],$row 2["Col3"],$row 2["Col5"],$row 2["Col5"],$row 2["Col6"]); Echo", <br/>"; $arr[]=intval($row 2["Col3"]); }        $arrchildid=intval($row["col2"]). ', '.implode(‘,‘,$arr); if($row["Col6"]== ")$row["Col6"]=$row["Col5"]; printf('%s ', 4, '%s ', '%s ', ' list.php?catid=%s ', 0, 0, 1, '%s ', '%s ', '%s ', '%s ', '%s '),$row["Col2"],$row["Col5"],$row["Col2"],$row["Col2"],$arrchildid,$row["Col2"],$row["Col5"],$row["Col5"],$row["Col6"]); Echo", <br/>"; }    Mysql_free_result($result); Mysql_free_result($result 2);?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.