Mysql を使ったデータベース PHPの実行結果をhtmlファイルとして書き出したいです
データベースはMysqlを使っていますがPHPの実行結果をhtmlファイルとして書き出したいのですが echo "<li class='active'><a href='special.php?page={$i}'>{$i}</a></li>";
のspecial.php?page={$i}'>{$i}
ができません!!
例えば:{$i}
が12の場合:special.php?page={$i}'>{$i}をspecial.html/12.html
のようにしたいです!!誰かご教授くださいませ!!
下記はテスト環境から本番環境にphpファイルを自動的にHTMLファイルに書き出すプログラムです:
syc.php
$url = "http://test.local/index.php";
$buff = file_get_contents($url);
$fname ="http://product/test.html";
$fhandle = fopen($fname, "w");
fwrite($fhandle, $buff);
fclose($fhandle);
?>
下記はテスト環境でのindex.phpファイルです:
<?php require_once("includes/header.php"); ?>
<?php require_once("includes/db.php"); ?>
<?php require_once("includes/navigation.php"); ?>
<div id="main" role="main">
<section class="slider">
<ul class="slides">
<li data-thumb="/slider/images"><a href="/"><img src="images" /></a></li></ul>
</section>
</div>
<ul>
<?php
$query = "SELECT * FROM test ORDER BY test_id DESC";
$query = mysqli_query($db, $query);
while($row = mysqli_fetch_assoc($query)){
$test_id = $row['test_id'];
$test_title = $row['test_title'];
$test_image = $row['test_image'];
?>
<li><a href="#"><img src="./images/<?php echo $test_image; ?>" alt="</a><a href="#"><?php echo $test_title;?></li>
<?php } ?>
</ul>
下記はincludes/navigation.phpファイルです:
<?php
ob_start();
?>
<nav class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<div class="menu">
<ul class="nav navbar-nav">
<?php
$query = "SELECT * FROM categories";
$cat_query = mysqli_query($db, $query);
while($row = mysqli_fetch_assoc($cat_query)){
$cat_title = $row['cat_title'];
$cat_id = $row['cat_id'];
$category_id = $row['category_id'];
}
?>
<?php echo "<li><a href='http://test.local/camera/index.php'>カメラ</a></li>"; ?>
<?php echo "<li><a href='http://test.local/iphone/'>携帯</a></li>"; ?>
</ul>
</div>
</div>
</div>
下記はcameraカテゴリ-の一覧を表示するindex.phpファイルです:
camera/index.php
<?php require_once("includes/db.php"); ?>
<?php require_once("includes/navigation.php"); ?></div>
<div class="container">
<?php
$per_page = 15;
if(isset($_GET['page'])){
$page = $_GET['page'];
} else{
$page = "";
}
if($page == "" || $page == 1){
$page_1 = 0;
}else{
$page_1 = ($page * $per_page) - $per_page;
}
$count = "SELECT * FROM camera";
$find_count = mysqli_query($db, $count);
$count = mysqli_num_rows($find_count);
$count = ceil($count / $per_page);
$query = "SELECT * FROM camera ORDER BY camera_id DESC LIMIT $page_1, $per_page";
$camera_query = mysqli_query($db, $query);
while($row = mysqli_fetch_assoc($camera_query)){
$camera_id = $row['camera_id'];
$camera_name = $row['camera_name'];
?>
<div>
<a href="camera.php?camera_id=<?php echo $camera_id; ?>">
<h3><?php echo $camera_name; ?></h3>
</div>
<ul class="pager">
<?php
for($i = 1; $i <= $count; $i++){
if($i == $page){
echo "<li class='active'><a href='camera.php?page={$i}'>{$i}</a></li>";
}else{
echo "<li><a href='camera.php?page={$i}'>{$i}</a></li>";
}
}
?>
</ul>
こちらは詳細ページのcamera.php
<?php require_once("includes/db.php"); ?>
<?php require_once("includes/header.php"); ?>
<?php require_once("includes/navigation.php"); ?>
<section>
<div class="col-md-8">
<?php
if(isset($_GET['camera_id'])){
$the_id = $_GET['camera_id'];
}
$query = "SELECT * FROM camera WHERE camera_id = $the_id";
$query = mysqli_query($db, $query);
while($row = mysqli_fetch_assoc($query)){
$camera_id = $row['camera_id'];
$camera_name= $row['camera_name'];
?>
<div><?php echo $camera_name; ?></div>