php處理行業分類資料

來源:互聯網
上載者:User

標籤:des   c   style   class   blog   code   

 實現步驟:

1.將excelTable Store為尾碼名為 .csv格式的檔案;

2.將.csv格式檔案匯入到mysql資料庫中;

3.通過條件查詢將所需要的資料查出並匯入另一個資料表中;

下面是一些php片段:

<?php    mysql_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 />";        $result2 = mysql_query("SELECT col3, col5, col6 FROM category where col3 like ‘".$row["col2"]."%‘");        $arr = array();        while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) {            if($row2["col6"]==‘‘) $row2["col6"]=$row2["col5"];            printf ("(‘%s‘, 4, ‘%s‘, ‘%s‘, ‘list.php?catid=%s‘, ‘%s‘, ‘%s‘, 0, ‘%s‘, ‘%s‘, ‘%s‘, ‘%s‘, ‘%s‘)",$row2["col3"],$row2["col5"],$row2["col3"],$row2["col3"],$row["col2"],‘0,‘.$row["col2"].‘,‘.$row2["col3"],$row2["col3"],$row2["col3"],$row2["col5"],$row2["col5"],$row2["col6"]);            echo ",<br />";            $arr[]=intval($row2["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($result2);?> 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.