2

最初に使用した構文は、このテーブルでは機能しませんでした。テーブル名を変更して、新しいテーブル用の新しい PHP ファイル (verinttable.php) を作成しました。これは、うまく動作しなかった新しい PHP ファイルです。最初の部分は、テーブル verint の構文です。2 つ目は、ページネーションの構文です。

     //verintable.php

<?php 
    include('config.php');
    require ('paginationverint.php');
    ERROR_REPORTING("E_ALL");
?>

//

<?php 
    include('config.php');
    require ('paginationverint.php');
    ERROR_REPORTING("E_ALL");
?>

//paginationverint.php



<?php
function pagination(){  
    if (isset($_POST['delete'])){

        $delete = $_POST['id'];
        $current = $_POST['current'];
        mysql_query("DELETE from verint WHERE critical_spare_id='$delete' ");


    }

    if (isset($_POST['update'])){

        $cid = $_POST['id']; 


    }

    if (isset ($_POST['updatee'])){

        $idd = $_POST['idd'];
        $client = $_POST['client'];
        $date = $_POST['date'];
        $availa = $_POST['avail'];
        $location = $_POST['location'];
        $class = $_POST['class'];
        $circuit = $_POST['circuit'];
        $version = $_POST['version'];
        $comcode = $_POST['comcode'];
        $serial = $_POST['serial'];
        $critid = $_POST['critid'];

        $query = mysql_query ("UPDATE verint SET 
                            `critical_spare_id` = '$critid',
                            `serial_no` = '$serial',
                            `comcode` = '$comcode',
                            `version` = '$version',
                            `circuit_pack` = '$circuit',
                            `classification` ='$class',
                            `location` = '$location',
                            `availability` = '$availa',
                            `date` = '$date',
                            `client` = '$client' WHERE 
                            `critical_spare_id` = '$idd'

                            ") or mysql_error();
        mysql_query($query);


    }

    if (isset($_GET['page'])) { $page = $_GET['page']; } else { $page = 1; }
    $a = 15;
    $start_from = ($page-1) * $a;
    $sql = "SELECT * FROM verint LIMIT $start_from, $a";
    $rs_result = mysql_query($sql);

    $query = mysql_query("SELECT COUNT(critical_spare_id) FROM verint");
    $num_rows = mysql_fetch_row($query);
    $total = $num_rows[0];
    $total_r = ceil($total/$a);
    echo "<center>-<b>There are $total products</b>-</center>";
    echo "<center>--<b>Page $page of $total_r</b>--</center>";
    echo "<center>";
    if ($page == 1){

    }else{

        echo " <a href='{$_SERVER['PHP_SELF']}?page=1'>First</a> ";

        echo " ";

        $previous = $page-1;

        echo " <a href='{$_SERVER['PHP_SELF']}?page=$previous'>Previous</a> ";

    }
    $range = 2;

    for ($x = ($page - $range); $x < (($page + $range) + 1); $x++) {

   if (($x > 0) && ($x <= $total_r)) {

      if ($x == $page) {

         echo " [<b>$x</b>] ";

      } else {

         echo " <a href='{$_SERVER['PHP_SELF']}?page=$x'>$x</a> ";
      } 
   } 
} 
    if ($page == $total_r){


    }else{

        $next = $page+1;

        echo " <a href='{$_SERVER['PHP_SELF']}?page=$next'>Next</a> ";

        echo " ";

        echo " <a href='{$_SERVER['PHP_SELF']}?page=$total_r'>Last</a> ";


    };
    echo "</center>";
?>
    <table border='1' align='center' class='hovertable'>
    <tr><th>Update</th><th>Delete</th><th>Critical Spare ID</th><th>Serial</th><th>Comcode</th><th>Version</th><th>Circuit Pack</th><th>Classification</th><th>Location</th><th>Availability</th><th>Date</th><th>Client</th></tr>
<?php
    while ($row = mysql_fetch_assoc($rs_result)){
    $spareid = $row['critical_spare_id'];
    $serial = $row['serial_no'];
    $code = $row['comcode'];
    $version = $row['version'];
    $circuit = $row['circuit_pack'];
    $class = $row['classification'];
    $location = $row['location'];
    $avail = $row['availability'];
    $date = $row['date'];
    $client = $row['client'];

?>
    <form method="post" action="<?php echo $PHP_SELF;?>" onSubmit="if(!confirm('Are you sure?'))return false;">
    <tr>

    <?php if (isset($_POST['update'])){ ?>
        <?php if($cid==$spareid){?>
        <td><input type=submit value='Update' name='updatee'><input type=hidden value='<?php echo $row['critical_spare_id'] ?>' name='idd' /></td>
        <td></td>
        <?php }else{?>
            <td><input type=submit value='Update' name='update'><input type=hidden value='<?php echo $row['critical_spare_id'] ?>' name='id' /></td>
            <td><input type=submit value='Delete' name='delete'><input type=hidden value='<?php echo $row['critical_spare_id'] ?>' name='id' /></td>
        <?php }?>
    <?php }else{?>
    <td><input type=submit value='Update' name='update'><input type=hidden value='<?php echo $row['critical_spare_id'] ?>' name='id' /></td>
    <td><input type=submit value='Delete' name='delete'><input type=hidden value='<?php echo $row['critical_spare_id'] ?>' name='id' /></td>
    <?php }?>

    <?php if (isset($_POST['update'])){?>
        <?php if($cid==$spareid){?>
        <td><input type=text value='<?php echo $spareid; ?>' name='critid' /></td>
        <?php }else{?>
        <td><?php echo $spareid;?></td>
        <?php }?>
    <?php }else{?>
    <td><?php echo $spareid;?></td>
    <?php }?>

    <?php if (isset($_POST['update'])){?>
        <?php if($cid==$spareid){?>
        <td><input type=text value='<?php echo $serial; ?>' name='serial' /></td>
        <?php }else{?>
            <td><?php echo $serial;?></td>
        <?php }?>
            <?php }else{?>
    <td><?php echo $serial;?></td>
    <?php }?>

    <?php if (isset($_POST['update'])){?>
        <?php if($cid==$spareid){?>
        <td><input type=text value='<?php echo $code; ?>' name='comcode' /></td>
        <?php }else{?>
            <td><?php echo $code;?></td>
        <?php }?>
            <?php }else{?>
    <td><?php echo $code;?></td>
    <?php }?>

    <?php if (isset($_POST['update'])){?>
        <?php if($cid==$spareid){?>
        <td><input type=text size='5' value='<?php echo $version; ?>' name='version' /></td>
        <?php }else{?>
            <td><?php echo $version;?></td>
        <?php }?>
            <?php }else{?>
    <td><?php echo $version;?></td>
    <?php }?>

    <?php if (isset($_POST['update'])){?>
    <?php if($cid==$spareid){?>
        <td><input type=text size='10' value='<?php echo $circuit; ?>' name='circuit' /></td>
        <?php }else{?>
            <td><?php echo $circuit;?></td>
        <?php }?>
            <?php }else{?>
    <td><?php echo $circuit;?></td>
    <?php }?>

    <?php if (isset($_POST['update'])){?>
    <?php if($cid==$spareid){?>
        <td><input type=text value='<?php echo $class; ?>' name='class' /></td>
        <?php }else{?>
            <td><?php echo $class;?></td>
        <?php }?>
            <?php }else{?>
    <td><?php echo $class;?></td>
    <?php }?>


    <?php if (isset($_POST['update'])){?>
    <?php if($cid==$spareid){?>
        <td><input type=text size='5' value='<?php echo $location; ?>' name='location' /></td>
        <?php }else{?>
            <td><?php echo $location;?></td>
        <?php }?>
            <?php }else{?>
    <td><?php echo $location;?></td>
    <?php }?>

    <?php if (isset($_POST['update'])){?>
    <?php if($cid==$spareid){?>
        <td><input type=text size='2' value='<?php echo $avail; ?>' name='avail' /></td>
        <?php }else{?>
            <td><?php echo $avail;?></td>
        <?php }?>
            <?php }else{?>
    <td><?php echo $avail;?></td>
    <?php }?>

        <?php if (isset($_POST['update'])){?>
    <?php if($cid==$spareid){?>
        <td><input type=text value='<?php echo $date; ?>' name='date' /></td>
        <?php }else{?>
            <td><?php echo $date;?></td>
        <?php }?>
            <?php }else{?>
    <td><?php echo $date;?></td>
    <?php }?>

        <?php if (isset($_POST['update'])){?>
    <?php if($cid==$spareid){?>
        <td><input type=text size='15' value='<?php echo $client; ?>' name='client' /></td>
        <?php }else{?>
            <td><?php echo $client;?></td>
        <?php }?>
            <?php }else{?>
    <td><?php echo $client;?></td>
    <?php }?>
    </tr>
    </form>

<?php
}
?>
</table>
<center>
<?php
    $sql = "SELECT COUNT(critical_spare_id) FROM verint";
    $rs_result = mysql_query($sql);
    $row = mysql_fetch_row($rs_result);
    $total_records = $row[0];
    $total_pages = ceil($total_records / $a);


    if ($page == 1){

    }else{

        echo " <a href='{$_SERVER['PHP_SELF']}?page=1'>First</a> ";

        echo " ";

        $previous = $page-1;

        echo " <a href='{$_SERVER['PHP_SELF']}?page=$previous'>Previous</a> ";

    }
    $range = 2;

    for ($x = ($page - $range); $x < (($page + $range) + 1); $x++) {

   if (($x > 0) && ($x <= $total_pages)) {

      if ($x == $page) {

         echo " [<b>$x</b>] ";

      } else {

         echo " <a href='{$_SERVER['PHP_SELF']}?page=$x'>$x</a> ";
      } 
   } 
} 
    if ($page == $total_pages){


    }else{

        $next = $page+1;

        echo " <a href='{$_SERVER['PHP_SELF']}?page=$next'>Next</a> ";

        echo " ";

        echo " <a href='{$_SERVER['PHP_SELF']}?page=$total_pages'>Last</a> ";


    };
}



?>
</center>
4

1 に答える 1

0

include_onceとrequire_onceを使用して、同じファイルを2回追加します。キーワードincludeを使用すると、ファイルは永続的に添付されます。もう一度含めようとすると、エラーが表示されます。

于 2012-05-04T06:39:18.650 に答える