if ( $action == "Drop" ) {
// Drop table Reports.
$conn->query( "DROP TABLE Reports" );
echo "Table Reports dropped";
}
|
elseif ( $action == "Create" ) {
// Create table Reports.
$sql = "CREATE TABLE Reports (
reportID INT NOT NULL AUTO_INCREMENT,
title VARCHAR(32) NOT NULL,
PRIMARY KEY( reportID ) )";
$conn->query( $sql );
echo "Table Reports created";
}
|
elseif ( $action == "Insert" ) {
// Insert reports.
$title = strtok( $_POST['titles'], " " );
while ( $title != false ) {
$sql = "INSERT INTO Reports( title ) VALUES( '$title' )";
$conn->query( $sql );
$title = strtok( " " );
}
// Select all reports.
$result = $conn->query( "SELECT * FROM Reports" );
while ( $row = $result->fetch_assoc( ) )
echo $row['reportID'] . ", " . $row['title'];
}
$conn->close( );
?>
</body></html>
|
|