相続、親が弱ってきたら銀行の預金は親の面倒を見ているものが全て解約して管理すべきである、銀行は解約させない!!

book php mysql css bootstrap

MySQL

bootstrap

cd /var/www/html/book

wget http://getbootstrap.com/2.3.2/assets/bootstrap.zip

unzip bootstrap.zip

cd bootstrap

cp -r * ..

 

vi /var/www/html/book/database-search-form.php

<!DOCTYPE html>
<html lang=”ja”>
<head>
<meta charset=”utf-8″>
<link href=”css/bootstrap.min.css” rel=”stylesheet”>
<script src=”js/bootstrap.min.js”></script>
</head>
<title> How To Create A Database Search With MySQL & PHP Script </title>

<body>
<div class=”container”>
<h3>How To Create A Database Search With MySQL & PHP</h3>
<form action=”php-database-search.php” method=”post”>
検索:<input type=”text” name=”search” placeholder=” 検索 … “/>
<input type=”submit” value=”送信” />
</form>
</div>
</body>
</html>

 

vi /var/www/html/book/php-database-search.php

<!DOCTYPE html>
<html lang=”ja”>
<head>
<meta charset=”utf-8″>
<link href=”css/bootstrap.min.css” rel=”stylesheet”>
<script src=”js/bootstrap.min.js”></script>
</head>

<body>
<div class=”container”>
<h3>MysqlとPHPでデーターベース検索</h3>
<form action=”php-database-search.php” method=”post”>
検索: <input type=”text” name=”search” placeholder=”検索…”/>
<input type=”submit” value=”送信” />
</form>
<?php
//load database connection
$host = “localhost”;
$user = “user”;
$password = “パスワード”;
$database_name = “book”;

$pdo = new PDO(“mysql:host=$host;dbname=$database_name”, $user, $password, array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
));
// Search from MySQL database table
$search=$_POST[‘search’];
$query = $pdo->prepare(“select * from book where title LIKE ‘%$search%’ OR author LIKE ‘%$search%’ LIMIT 0 , 10”);
$query->bindValue(1, “%$search%”, PDO::PARAM_STR);
$query->execute();
// Display search result
if (!$query->rowCount() == 0) {
?>

検索結果 :<br/>
<table class=”table table-striped table-bordered table-hover”>
<thead>
<tr>
<th>題名</th>
<th>著者</th>
<th>価格</th>

</thead>

<?php
while ($results = $query->fetch()) {
?>

<tbody>
<tr>
<td><?php echo $results[‘title’]; ?></td>
<td><?php echo $results[‘author’]; ?></td>
<td><?php echo “$”.$results[‘price’]; ?></td>
</tr>
<?php
}
?>

</tbody>
</table>
<?php
} else {
echo ‘Nothing found’;
}
?>

MySQLPHP
スポンサーリンク
シェアする
ふじやんをフォローする
スポンサーリンク
なんでもDIY

コメント