Home > Backend Development > PHP Tutorial > PHP implements SQL Server data import into Mysql database (example)

PHP implements SQL Server data import into Mysql database (example)

WBOY
Release: 2016-07-25 08:54:58
Original
1116 people have browsed it
  • < ;td align="center">author
  • $ms_query=mssql_query("select * from $db_database",$conn);
  • while($msrow=mssql_fetch_array($ms_query)){
  • $name=$msrow[name]; //for output Set a variable for the content
  • $author=$msrow[author];
  • $bookconcern=$msrow[bookconcern];
  • ?>
    1. //Connect to SQL server database
    2. $conn=mssql_connect("localhost","sa",""); //Server name, username, password
    3. mssql_select_db("db_database06", $conn); //Connect to table_book database
    4. //Connect to mysql database
    5. $id=mysql_connect("localhost","root","123456"); //Local server localhost, username root, password root
    6. mysql_select_db(" db_database06",$id);
    7. mysql_query("set names gb2312"); //Connect to the shop_book database
    8. //Query all the contents of the data table book from the SQL server database
    9. ?>
    10. SQL Server data is imported into the MySQL database_bbs.it-home.org
    11. Please select the data table
    12. < table width="450" ​​border="1" cellpadding="0" cellspacing="0" bgcolor="#B4EEF1">
    Export the contents of the SQLserver data table
    name bookconcern
  •   ;  < ;/td>
  • if($Submit2==true ){
  • $query=mysql_query("insert into tb_book(name,author,bookconcern)
  • values('$name','$author','$bookconcern')",$id);
  • }
  • if($query ==true){
  • echo "Import successful!!";
  • }else{echo "Import failed!!";}
  • ?>
  • $query=mysql_query("select * from tb_book");
  • if($query==true){
  • while($myrow=mysql_fetch_array($query)){
  • ?>
  • 成功导入的数据
    name author bookconcern
  • 复制代码


    source:php.cn
    Previous article:5 ways to create arrays in PHP Next article:A small example of replacing array key names in PHP
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Latest Articles by Author
    Latest Issues
    Related Topics
    More>
    Popular Recommendations
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template