Skip to content

Instantly share code, notes, and snippets.

@BlogBlocks
Last active December 8, 2017 13:47
Show Gist options
  • Save BlogBlocks/4a264fa4ff42fcc6aaa5 to your computer and use it in GitHub Desktop.
Save BlogBlocks/4a264fa4ff42fcc6aaa5 to your computer and use it in GitHub Desktop.
Online Data-based Book Creator with Search
<div id="header">
<h1>Tales of the Saltman</h1>
<p>by Jack Northrup</p>
<a class="right" href="index.php">Home</a>
</div>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Jack Northrup" />
<title>SALTMAN</title>
<link rel="stylesheet" href="story.css" />
</head>
<body>
<div id="wrapper">
<?php include('admin-header.php'); ?>
<div id="center-column">
<div id="post"><br />
<form action="document-insert.php" method="post">
Chapter Number:&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="chapnum" value="" width="50px"/><br /><br />
Chapter Name:&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="chapter" value=""/><br />
Keywords:&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="keywords" value=""/><br />
Content:<textarea cols="70" rows="10" name="entry" value="text"></textarea><br /><br />
<input type= "submit" name= "submit" value="Enter"/>
</form> <br />
<label>
<a class="notice" href="read-id-u.php" target="_blank">Notebook EDITOR - Edit and Repost</a>
</label>
<br /><br />
<br /><br />
<form method="post" action="delete.php">
To Delete Notebook Entry - Enter edit id-<input name="id" type="text" id="id" />
<input name="delete" type="submit" id="delete" value="ENTER TO DELETE" />
</form>
<br />
</div>
<div id="read">
<?php include('local-connect.php'); ?>
<?php
//execute the SQL query and return records
$result = mysql_query("SELECT * FROM `ver_2016`"
. " ORDER BY `ID` DESC LIMIT 5 ");
//fetch the data from the database
?>
<div class="boxit">
<?php include('read-only-inc.php'); ?>
</div>
<?php mysql_close($dbhandle); ?>
</div>
</div>
<?php
if(isset($_POST['delete']))
{
$hostname = "localhost";
$username = "root";
$password = "";
$con = mysql_connect($hostname, $username, $password);
if(! $con )
{
die('Could not connect: ' . mysql_error());
}
//$id = $_POST['id'];
$sql = "DELETE FROM ver_2016 WHERE ID={$_POST['id']} LIMIT 1";
//$sql = "DELETE comments ".
// "WHERE id = $id" ;
mysql_select_db('story');
$retval = mysql_query( $sql, $con );
if(! $retval )
{
die('Could not delete data: ' . mysql_error());
}
echo "Deleted data successfully\n";
mysql_close($con);
}
?>
<div id="post">
<p>Concerning What File?</p><br />
<form action="document-insert.php" method="post">
Title:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="title" value=""/>
<br /><br />
Keywords:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="category" value=""/>
<br /><br />
Description:&nbsp;&nbsp;<textarea cols="70" rows="3" name="description" value="text"></textarea>
<br /><br />
Content:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<textarea cols="70" rows="10" name="content" value="text"></textarea>
<br /><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type= "submit" name= "submit" value="Enter"/>
</form> <br /><br />
<ul><h1 style="color:gray; font-size:120%;">TEXT EDITORS</h1><br />
<li><a href="css/start.php" target="_blank">Text/Css Editor</a></li><br />
<li><a href="start.php" target="_blank">Text Comments Editor</a><abr /></a>
<br /></li><h4>Edit comments in "posted_text.html"</h4><br />
<li><a href="posted_text.html" target="_blank">View text comments</a></li>
</ul>
<br />
</div>
<?php
$hostname = "localhost";
$username = "root";
$password = "";
$database = "stories";
$con=mysqli_connect("$hostname","$username","$password","$database");
// Check connection
if (mysqli_connect_error())
{
echo "Failed to connect to MySQL SERVER: " . mysqli_connect_error();
}
$sql="INSERT INTO ver_2016 (id, chapnum, chapter, entry, keywords)
VALUES
('','$_POST[chapnum]','$_POST[chapter]','$_POST[entry]','$_POST[keywords]')";
if (!mysqli_query($con,$sql))
{
die('Error - Failed to post: ' . mysqli_error($con));
}
mysqli_close($con);
header("Location: index.php");
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta content="Jack Northrup " name="author" />
<title>Story-Edit</title>
<link rel="stylesheet" href="documents.css" />
</head>
<body>
<div id="wrapper">
<?php include('story-header.php'); ?>
<div id="center-column">
<?php include('doc-post.php'); ?>
<?php include('read-inc.php'); ?>
<?php include('document-footer-inc.php'); ?>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Jack Northrup" />
<title>SALTMAN</title>
<link rel="stylesheet" href="story.css" />
</head>
<body>
<div id="wrapper">
<?php include('story-header.php'); ?>
<div id="center-column">
<div id="read-text">
<form style="text-align:center;" action="read-search.php" method="get"><br />
<input type="text" name="query" />
<button>Chapter or Search</button>
</form>
</div>
<?php include('read-only-inc.php'); ?>
</div>
</div>
</body>
</html>
<?php
$hostname = "localhost";
$username = "root";
$password = "";
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
$selected = mysql_select_db("stories",$dbhandle)
or die("Could not select the stories database");
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Jack Northrup" />
<title>Story Editor</title>
<link rel="stylesheet" href="story.css" />
<script>var textarea = document.getElementById('entry');
textarea.scrollTop = textarea.scrollHeight;</script>
</head>
<body>
<div id="editor-wrapper">
<?php include('admin-header.php'); ?>
<br /><br />
<form action="" method="get">
<button type="submit">Enter ID Number: edit-</button>
<input type="text" name="data" />
</form>
<?php include('local-connect.php'); ?>
<?php $data = $_GET['data'];
$query = "SELECT * FROM ver_2016 WHERE Id='$data'";
$result = mysql_query($query);
$data = mysql_fetch_assoc($result);
?>
<form action="story-update.php" method="post">
<br />
Verify ID:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="id" value="<?php echo $data['id']; ?>"/><br /><br />
Chapter Number:&nbsp;<input type="text" name="chapnum" value="<?php echo $data['chapnum']; ?>"/><br /><br />
Chapter Name:<br />
<input type="text" name="chapter" value="<?php echo $data['chapter']; ?>"/><br /><br />
Content:<br />
<textarea name="entry">
<?php echo $data['entry']; ?>
</textarea><br /><br />
<input type= "submit" name= "submit" value="Enter"/>
Keywords:&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="keywords" value="<?php echo $data['keywords']; ?>"/><br /><br />
</form>
</div>
</body>
</html
<div id="read-only">
<?php include('local-connect.php'); ?>
<?php
$result = mysql_query("SELECT * FROM `ver_2016`"." ORDER BY `ID` LIMIT 0, 9 ");
?>
<div id="boxit">
<?php
while ($row = mysql_fetch_array($result)) {
echo "<hr>edit-
".$row['id']."<br><br><br />Chapter:&nbsp;
".$row['chapnum']."&nbsp;&nbsp;<h2>
".$row['chapter']."<br /></h2><p>
".$row['entry']."</p><br><br><br />KEYWORDS:&nbsp;&nbsp;
".$row['keywords']."<br /><hr><br />"; }
?>
</div>
<?php
//close the connection
mysql_close($dbhandle);
?>
</div>
<div id="read-only">
<?php include('doc-data-connect.php'); ?>
<?php
$query = $_GET['query'];
$min_length = 1;
if(strlen($query) >= $min_length){
$query = htmlspecialchars($query);
$query = mysql_real_escape_string($query);
$raw_results = mysql_query("SELECT * FROM ver_2004
WHERE (`description` LIKE '%".$query."%') OR (`category` LIKE '%".$query."%')") or die(mysql_error());
?>
<div class="boxit">
<?php
if(mysql_num_rows($raw_results) > 0){
while($results = mysql_fetch_array($raw_results)){
echo "<p><h3>".$results['id']."&nbsp;&nbsp;".$results['category']."</h3>".$results['description']."</p>"."<p>".$results['content']."</p>.";
}}
else{
echo "No results";
}}
else{
echo "Minimum length is ".$min_length;
}
?>
<?php
//close the connection
mysql_close($dbhandle);
?>
</div>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="keywords" content="Notes Mini-Blog, SQL comments, online comments, sql based comments, comments code" />
<meta name="description" content="Documentation for Notes Mini-Blog ver 2.04 is an MySQLbased online documentation. It is a works in progress. It will soon be a fully searchable BlogBlocks Documentation Source." />
<meta content="Jack Northrup " name="author" />
<title>Tales of the Saltman</title>
<link rel="stylesheet" href="documents.css">
</head>
<body>
<div id="wrapper">
<?php include('document-header-inc.php'); ?>
<div id="center-column">
<?php include('read-only-inc.php'); ?>
<?php include('document-footer-inc.php'); ?>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<head>
<title>Saltman Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="keywords" content="Notes Mini-Blog, SQL comments, online comments, sql based comments, comments code" />
<meta name="description" content="Online Story" />
<meta content="Jack Northrup " name="author" />
<link rel="stylesheet" href="story.css" />
</head>
<body>
<div id="wrapper">
<?php include('admin-header.php'); ?>
<div id="center-column">
<form style="text-align:center;" action="read-search1.php" method="get"><br />
<input type="text" name="query" />
<button>Chapter or Search</button>
</form>
<?php include('local-connect.php'); ?>
<div id="read-search">
<?php
$query = $_GET['query'];
$min_length = 5;
if(strlen($query) >= $min_length){
$query = htmlspecialchars($query);
$query = mysql_real_escape_string($query);
$raw_results = mysql_query("SELECT * FROM ver_2016
WHERE (`chapter` LIKE '%".$query."%') OR (`keywords` LIKE '%".$query."%')") or die(mysql_error());
if(mysql_num_rows($raw_results) > 0){
while($results = mysql_fetch_array($raw_results)){
echo "id#".$results['id']."<br>Chapter ".$results['chapnum'].$results['chapter']."<br>".$results['entry'].$results['keywords'];
}
}
else{
echo "No results";
}}
else{
echo "Minimum length is ".$min_length;
}
?>
</div>
<?php include('story-footer.php'); ?>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<head>
<title>Saltman Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="keywords" content="Notes Mini-Blog, SQL comments, online comments, sql based comments, comments code" />
<meta name="description" content="Online Story" />
<meta content="Jack Northrup " name="author" />
<link rel="stylesheet" href="story.css" />
<script type="text/javascript" src="https://apis.google.com/js/platform.js"></script>
</head>
<body>
<div id="wrapper">
<?php include('admin-header.php'); ?>
<div id="center-column">
<?php include('local-connect.php'); ?>
<div id="read-search">
<?php
$query = $_GET['query'];
$min_length = 5;
if(strlen($query) >= $min_length){
$query = htmlspecialchars($query);
$query = mysql_real_escape_string($query);
$raw_results = mysql_query("SELECT * FROM ver_2016
WHERE (`chapter` LIKE '%".$query."%') OR (`keywords` LIKE '%".$query."%')") or die(mysql_error());
if(mysql_num_rows($raw_results) > 0){
while($results = mysql_fetch_array($raw_results)){
echo $results['id']."<br> Chapter ".$results['chapnum']"<br />.$results['chapter']."<br>".$results['entry'].$results['keywords'];
}
}
else{
echo "No results";
}}
else{
echo "Minimum length is ".$min_length;
}
?>
</div>
<?php include('story-footer.php'); ?>
</div>
</div>
</body>
</html>
<div id="header">
<h1>REVIEW</h1>
<p>Tales of the Saltman</p>
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="admin-login.php">Admin for Re-Edit</a></li>
</ul>
</div>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><title>Online NoteBook</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta content="Jack Northrup " name="author" />
<link rel="stylesheet" type="css/text" href="story.css" />
</head>
<body>
<div id="wrapper">
<?php include('review-header.php'); ?>
<?php include('local-connect.php'); ?>
<?php
$result = mysql_query("SELECT * FROM `ver_2016`". " ORDER BY `ID` DESC LIMIT 1 ");
//fetch tha data from the database
?>
<div id="boxit">
<?php
while ($row = mysql_fetch_array($result)) {
echo "<hr>edit-".$row['id']."<br><br><br />Chapter:&nbsp;
".$row['chapnum']."&nbsp;&nbsp;<h2>".$row['chapter']."<br /></h2><p>
".$row['entry']."</p><br><br><br />KEYWORDS:&nbsp;&nbsp;
".$row['keywords']."<br /><hr><br />"; }
?>
</div>
</div>
</body>
</html>
<div id="header">
<h1>Tales of the Saltman</h1>
<p>by Jack Northrup</p>
<a class="right" href="admin-login.php">Admin</a>
</div>
<?php
$hostname = "localhost";
$username = "root";
$password = "";
$database = "story";
$con = mysqli_connect("$hostname", "$username", "$password", "$database");
// Check connection
if (mysqli_connect_error()) {
echo "Failed to connect to MySQL SERVER: " . mysqli_connect_error();
}
$sql = "INSERT INTO ver_2016 (id, chapnum, chapter, entry, keywords)
VALUES
('','$_POST[chapnum]','$_POST[chapter]','$_POST[entry]','$_POST[keywords]')";
if (!mysqli_query($con, $sql)) {
die('Error - Failed to post: ' . mysqli_error($con));
}
mysqli_close($con);
header("Location: index.php");
?>
/*
Theme Name: BlogBlock BookMaker ver 2.04
Theme URI: http://www.blogblocks.net
Description: BlogBlock Blog theme BookMaker
Author: Jack Northrup
Author URI: http://jacknorthrup.com
Template: Create a Book
Version: 3.0.4
*/
html{
margin:0;
padding:0;
/* background-image: url(file-background.jpg); */
}
body{
margin:0;
padding:0;
background: #cccc99;}
/* background-image: url(file-background.jpg); } */
h1, h2, h3, h4, h5, h6,
article, applet, audio, body, caption, center,
del, dd, div, dl, dt, em, embed, footer, form, header, html,
i, iframe, input, img, label, li, legend, menu, nav, ol,
object, output, p, section, select, span, table, tbody, textarea, tfoot, thead, tr, th, td, ul, video {
margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit;
}
article,footer, header, menu, nav, section { display: block;
}
a {margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit;
color: inherit; outline: none; text-decoration: none; text-align:right;
}
blockquote, q {quotes: none;}
body {line-height: 1;
font-size:20px;}
caption, th {text-align:center;}
img {border: 0;}
legend {color: #000;}
ol, ul {list-style: none;}
table {border-collapse: collapse; border-spacing: 0;
}
#wrapper{
margin:5px auto;
width:98%;
max-width:1000px;
height:auto;
min-height:2350px;
padding-top:5px;
padding-right:.5%;
padding-left:.5%;
padding-bottom:15px;
border:1px solid gray;
border-radius:8px;
}
#editor-wrapper{
margin:5px auto;
width:98%;
max-width:1000px;
height:auto;
min-height:900px;
padding-top:5px;
padding-right:.5%;
padding-left:.5%;
padding-bottom:15px;
border:1px solid gray;
border-radius:8px;
}
textarea {
width: 100%;
height:auto;
min-height:300px;
}
input[name=chapter] {
width: 100%;
font-size: 1.5em;
height: 40px;
display: block;
margin-bottom: 10px;
background-color: #F8F6B4;
}
input[name=keywords] {
width: 100%;
font-size: 1.5em;
height: 40px;
display: block;
margin-bottom: 10px;
background-color: #F8F6B4;
}
input[name=category] {
width: 100%;
font-size: 1.5em;
height: 25px;
display: block;
margin-bottom: 10px;
background-color: #F8F6B4;
}
input[name=query] {
width: 65%;
font-size: 1.5em;
height: 35px;
margin-bottom: 10px;
background-color: #F8F6B4;
border-radius: 8px;
}
button {
background-color: gray;
border: none;
color: white;
padding: 5px 15px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
margin: 4px 2px;
cursor: pointer;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
button:hover {
background-color: gray;
border: none;
color: white;
padding: 5px 15px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
margin: 4px 2px;
cursor: pointer;
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.44), 0 17px 50px 0 rgba(0,0,0,0.29);
}
.video-container iframe,
.video-container object,
.video-container embed {
position: absolute;
top: 0;
left: 5%;
width: 90%;
height: 90%;
}
.entry-content img,
.entry-content iframe,
.entry-content object,
.entry-content embed {
max-width: 100%;
}
#header{
margin: auto;
width: 98%;
border: 1px solid #660000;
height:auto;
}
#header h1{
font-size: 2em;
text-align: center;
padding-right:5px;
color: #660000;
}
#header p{
font-size: 1em;
text-align: center;
padding-right:5px;
color: #660000;
}
#header a{
font-size: 1em;
text-align: center;
padding:5px;
}
.right{
text-align:right;
}
#boxit h2{
font-size: 1.6em;
text-align: center;
padding-right:5px;
color: #660000;
}
#boxit p{
font-size: 1.2em;
width: 95%;
text-align: justify;
padding-right:5px;
color: #660000;
}
label{
padding:5px;
border: 1px solid black;
color:red;
}
/* end */
-- phpMyAdmin SQL Dump
-- version 4.5.2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Mar 13, 2016 at 05:25 AM
-- Server version: 10.1.9-MariaDB
-- PHP Version: 5.6.15
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `stories`
--
-- --------------------------------------------------------
--
-- Table structure for table `ver_2016`
--
CREATE TABLE `ver_2016` (
`id` mediumint(6) NOT NULL,
`chapnum` varchar(4) NOT NULL,
`chapter` varchar(100) NOT NULL,
`entry` varchar(50000) NOT NULL,
`keywords` varchar(4000) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `ver_2016`
--
INSERT INTO `ver_2016` (`id`, `chapnum`, `chapter`, `entry`, `keywords`) VALUES
(5, '1', 'The Year of the Rats', 'Due to effects of rising ...', 'rats, coast');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `ver_2016`
--
ALTER TABLE `ver_2016`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `ver_2016`
--
ALTER TABLE `ver_2016`
MODIFY `id` mediumint(6) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
@BlogBlocks
Copy link
Author

This is an online book creator. The entries are stored in a database, by chapter. The book is searchable by title or by keywords.
entries can be deleted or edited. An edit displays the entry that requires editing and the save is a new database entry. Thus, edits are non-destructive and remain until deleted.
The download should work as soon as a database named [ stories ] is created and the [ ver_2016.sql ] file is imported. It is currently configured to root with no password.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment