I want to export the results of database PHP execution using Mysql as an html file.

Asked 2 years ago, Updated 2 years ago, 49 views

The database uses Mysql, but I would like to export PHP results as an html file, but echo"<licclass='active'><a href='special.php?page={$i}'>{$i}</a>><</li>;;;;{/code>{ipode.} of $ipage}? For example: If {$i} is 12: I want special.php?page={$i}'>{$i} to be special.html/12.html!!Please tell me who it is!!

Below is a program that automatically writes php files from the test environment to the production environment into HTML files:
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);
?>

Below is the index.php file in the test environment:

<?php require_once("includes/header.php");?>
<?php require_once("includes/db.php");?>
<?php require_once("includes/navigation.php");?>
<divid="main" role="main">
    <section class="slider">
        <ul class="slides">
            <lidata-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_try;>>>? 
    <?php}?>
    </ul>

Below is the include/navigation.php file:

<?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'];
                    }
                ?>
                <?phpecho"<li><a href='http://test.local/camera/index.php'>Camera</a></li>";?>
                <?php echo"<li><a href='http://test.local/iphone/'>Cellular</a></li>";?>
            </ul>
      </div>
    </div>
</div>

Below is the index.php file that lists the camera categories:

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><?phpecho$camera_name;?>/h3>
</div>
<ul class="pager">
<?php
    for($i=1;$i<=$count;$i++){
        if($i==$page){
            echo"<lic class='active'><a href='camera.php?page={$i}'>{$i}</a></li>";
        } else {
            echo "<li><a href='camera.php?page={$i}'>{$i}</a></li>";
        }
    }
?>
</ul>

This is camera.php

on the detail page.
<?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><?phpecho$camera_name;?>/div>

php mysql

2022-09-30 14:35

1 Answers

If you focus on the output,
Path reference may be strange

<?php
$url="http://test.local/index.php";
$buff=file_get_contents($url);
//fopen references are relative paths or absolute paths from the root
$fname="./test.html";
$fname="/var/www/html/test.html";

$fhandle=fopen($fname, "w");
fwrite($fhandle,$buff);
fclose($fhandle);
?>


2022-09-30 14:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.