单个mysqli_result中的多个查询

时间:2011-01-19 23:32:12

标签: php mysql

我想知道如何在一个mysqli_result中运行两个单独的查询。 我在这里看到的很明显。非常感谢任何帮助。

<?php 
$dbc=mysqli_connect("localhost", "XXXXX", "xxxx", "XXXXXXXX")
            or die('Error connecting to MySQL server.');

$Query = 'CREATE TABLE table_name (
    user_id INT AUTO_INCREMENT,
    username VARCHAR(32), 
    password VARCHAR(40),
    join_date DATETIME,
    first_name VARCHAR (32),
    last_name VARCHAR (32),
    gender VARCHAR (1),
    birthdate DATE,
    city VARCHAR(32),
    state VARCHAR(2),   
    picture VARCHAR(32),
    PRIMARY KEY(user_id)

    )";

INSERT INTO table_name VALUES (1, 'sidneyk', SHA('sidney'), '2008-06-03 14:51:46', 'Sidney', 'Kelsow', 'F', '1984-07-19', 'Tempe', 'AZ', 'sidneypic.jpg')";
INSERT INTO table_name VALUES (2, 'nevilj', SHA('nevil'), '2008-06-03 14:52:09', 'Nevil', 'Johansson', 'M', '1973-05-13', 'Reno', 'NV', 'nevilpic.jpg')";
INSERT INTO table_name VALUES (3, 'alexc', SHA('alex'), '2008-06-03 14:53:05', 'Alex', 'Cooper', 'M', '1974-09-13', 'Boise', 'ID', 'alexpic.jpg')";

if(mysqli_query($dbc, $Query)) {
    print("The query was successfully executed!<br />");
} else {
    print("The query could not be executed!" . mysql_error());
}

mysqli_close($dbc);

&GT;

1 个答案:

答案 0 :(得分:5)

请参阅mysqli_multi_query()功能。