PHP Read access data to MySQL code _php tutorial

Source: Internet
Author: User
Copy CodeThe code is as follows:
Header (' ontent-type:text/html;charset=gb2312 ');//Avoid garbled output
$dbhost = "localhost";
$dbuser = "root";
$dbpassword = "123456";
$dbname = "139miaosha";
Mysql_connect ($dbhost, $dbuser, $dbpassword) or Die ("error!");
mysql_query ("Set names ' GBK '");
mysql_select_db (' 139miaosha ');
$conn = new COM ("ADODB. Connection ");
$connstr = "Driver=microsoft Access DRIVER (*.mdb);D Bq=f:/wamp/www/miaosha/ruichao858.mdb";
$conn->open ($CONNSTR);
$rs = new COM ("ADODB. RecordSet ");
$rs->open ("select * from News where bigclassname= ' decoration class '", $conn, 1, 3);
while (! $rs->eof) {
Switch ($rs->fields[4]) {
Case "Decoration Consultant":
$sclass = 1;
Break
Case "kitchen and bathroom space":
$sclass = 2;
Break
Case "Furniture Language":
$sclass = 3;
Break
Case "Electrical Engineering":
$sclass = 4;
Break
Case "Home decoration Landscape":
$sclass = 5;
Break
Case "Material Wide angle":
$sclass = 6;
Break
Default
$sclass = 1;
}
if ($rs->fields[6]) {
$spic = "";
}else{
$spic = $rs->fields[6];
}
if ($rs->fields[7]) {
$user = "";
}else{
$user = $rs->fields[7];
}
if ($rs->fields[9]) {
$hits = 1;
}else{
$hits = $rs->fields[9];
}
$sql = "INSERT into Rc_news (N_title,n_content,n_bclass,n_sclass,n_pic,n_spic,n_user,n_hits,n_audit) VALUES ('". $rs- >FIELDS[1]. "', '". $rs->fields[2]. "', 1,". $sclass. "," ",". $spic. "', '". $user. "',". $hits. ", 1)";
$result =mysql _query ($sql);
Echo $rs->fields[1];
echo "
";
$rs->movenext (); Move the recordset pointer down
}
$rs->close ();
?>

http://www.bkjia.com/PHPjc/323349.html www.bkjia.com true http://www.bkjia.com/PHPjc/323349.html techarticle Copy the code as follows: PHP header (' ontent-type:text/html;charset=gb2312 ');//Avoid garbled output $dbhost = "localhost"; $dbuser = "root"; $ Dbpassword = "123456"; $dbname = "139mia ...

  • 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.