doing mysql stuff

cat-town
Dan Buch 14 years ago
parent 38cef44836
commit 2d9cd9de75

@ -0,0 +1,58 @@
<?php
$MYSQL_CXN = mysqli_connect(
"localhost",
"learningphp",
"learningphp",
"learningphp"
);
require_once("_head.php");
function create_all_tables($cxn) {
return @mysqli_query($cxn, file_get_contents("../setup.sql"));
};
mkheader("mysql!", '#aff');
?>
<body>
<!-- ======================================================= -->
<pre><?php
print "\$MYSQL_CXN:\n";
print_r($MYSQL_CXN);
?></pre>
<?php
if ($_POST['create'] == "yes") {
create_all_tables($MYSQL_CXN);
?>
<pre><?php
print_r(mysqli_query($MYSQL_CXN, "DESCRIBE customers"));
print_r(mysqli_query($MYSQL_CXN, "SELECT * FROM customers"));
?></pre><a href="<?php echo $_SERVER['PHP_SELF']; ?>">clear</a><?php
} else {
?>
<form name="setup" action="" method="POST">
<input type="hidden" name="create" value="yes" />
<input type="submit" name="submit" value="Create Tables" />
</form>
<?php
}
?>
</body>
</html>

@ -0,0 +1,6 @@
CREATE TABLE IF NOT EXISTS customers (
customer_id INTEGER,
name VARCHAR(255),
email VARCHAR(255),
PRIMARY KEY(customer_id)
);
Loading…
Cancel
Save