Oicq turning OICQ data into MySQL data

Source: Internet
Author: User
This file is/tmp/phpbeojq5.
################# can copy this code to test #################
Include ("Include/dbclass.inc"); You can use MYSQL. INC instead of testing
$q = new Db_sql;
$db = $q->database; Define the database
mysql_connect (' localhost:3306 ', $q->user, $q->password);
?>

function Show_field ($db, $table, $num, $selected _field) {
$result = Mysql_db_query ($db, "SHOW KEYS from $table") or Mysql_die ();
$primary = "";
while ($row = Mysql_fetch_array ($result))
if ($row ["key_name"] = = "PRIMARY")
$primary. = "$row [column_name],";
$result = Mysql_db_query ($db, "SHOW fields from $table");
if (! $result) {
Mysql_die ();
}
else {
echo " n "; while ($row = Mysql_fetch_array ($result)) {$selected = ($selected _field = = $row ["field"])? "Selected": ""; echo "" . $row ["Field"]. "N"; } echo "nn ";
}
}
function show_table ($db, $selected _table) {
$tables = Mysql_list_tables ($db);
$num _tables = @mysql_numrows ($tables);
if ($num _tables = = 0) {
echo "no table yet";
}
else {
$i = 0;
echo " n "; while ($i < $num _tables) {$table = Mysql_tablename ($tables, $i); $selected = ($selected _table = = $table)? "Selected": ""; echo "$tablen "; $i + +; } echo "nn ";
}
}
if ($submit) {
if (!empty ($csv _file) && $csv _file! = "None") {
$csv _file = stripslashes ($csv _file);
$fp = fopen ($csv _file, "R");
Show first line of the CSV file to select Dababase table and its fields
echo "

n ";
When click ' OK ' button, start insert data
if ($submit = = "OK") {
$NO = 1;
while ($csv _data = Fgetcsv ($fp, $, "$terminated")) {
$num = count ($csv _data);
for ($c =0; $c < $num; $c + +) {
$table _field_name = "Field$c";
$first _3 = substr ($ $table _field_name, 0, 3);
$first _2 = substr ($ $table _field_name, 0, 2);
$val _tmp = ($first _3 = = "FID" | | $first _3 = = "int"
|| $first _2 = = "id")?
$csv _data[$c]: "'". $csv _data[$c]. "'";
$val. = $val _tmp. ",";
$var. = $ $table _field_name. ",";
}
$val = substr ($val, 0,-1);
$var = substr ($var, 0,-1);
$query = "INSERT into $table ($var) VALUES ($val)";
$val = "";
$var = "";
$q->query ($query);
echo "NO. $NO $query

";
$NO + +;
}
Fclose ($FP);
}
}
}
?>

The above describes the OICQ OICQ data into MySQL data, including OICQ aspects of the content, I hope the PHP tutorial interested in a friend to help.

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