Page 1 of 1

Basic variable questiosn

Posted: Wed Dec 16, 2009 9:20 am
by RIGOLETO
Hi there,

I have a problem with two diferentes browsers, just I have a varibale tha is keeping the current page numbrer, for instance if I go to page twe that var is storing 2 but if I call a new page browser then I am missing the variable value, my problem is when I back to my table it is go to the first page and it should back to the second page selected.

Rigi

Re: Basic variable questiosn

Posted: Wed Dec 16, 2009 9:27 am
by aravona
Can you post the code to get a better idea of whats going on?

Re: Basic variable questiosn

Posted: Wed Dec 16, 2009 9:36 am
by RIGOLETO
this is the idea, I have populated a table, this table has diferent options, just like VIEW, EDIT, DELETE and Print, also it has a paging portion of code, well the problems is when I make a VIEW, just I am making that view in page 2 of the table, a new browser is called but the page numer is missing, so the program is rebuilding the table or populating it like new call, I mean , the program found the page control like 1.


I need to call a diferentes browser and not miss my PAGE variable value, the will help me to back to the original page

Code: Select all

 
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="css/cara.css" rel="stylesheet" type="text/css" />
        <title>MIS Inventory</title>
 
 
 
    </head>
    <body>
        <form method="POST" action="Main_menu.php">
 
 
 
            <table class="bd" width="100%"><tr><td class="hr"><h1>MIS INVENTORY</h1></td></tr></table>
            <table class="bd" width="100%"><tr><td class="hr"> <h2>Mantenance Hardware Inventory</h2></td></tr></table>
            <input type="submit" value="Back Main Menu" />
 
 
 
 
            <tr> <td><a href="AddNewHardwareRecord.php?a=add"> <h4>Add a new record</h4></a>&nbsp; &nbsp;</td></tr>
 
 
 
 
 
 
            <?php
 
            include("ConeccionaBD.php");
            $link=Conectarse();
            
            $limite =6;
            $cantidad = @mysql_query("SELECT * FROM hardware_inventory");
            $total = mysql_num_rows($cantidad);
            $pagina =$_GET['pagina'];
            if(empty($pagina)) {
            // Estamos en la primera página
                $pagina = 1;
            }
            $valor_limite = $pagina * $limite - ($limite);
 
            $result1= mysql_query("select * from hardware_inventory ",$link);
            $totalreg=mysql_num_rows($result1);
 
            $result=mysql_query("select * from hardware_inventory LIMIT $valor_limite, $limite",$link) or die("invalid table");
            $total_paginas =ceil($totalreg/$registros);
 
            ?>
            <?php
 
            if($pagina != 1) {
 
                $pagina_anterior = $pagina - 1;
                // debemos escapar las comillas dobles en el hipervínculo
                echo "<a href=MantHardwareInventory.php?pagina=$pagina_anterior>   Previous   </a>";
            } else {
            // Si estamos en la primera página, no creamos el vínculo
                echo "Previous";
            }
            // El número total de páginas. No importa que este no sea un número exacto (por ejemplo
            // 80/25 = 3.2) pues siempre comprobamos por el número entero menor.
            $numero_de_paginas = $total / $limite;
            for($i = 1; $i <= $numero_de_paginas; $i++) {
                if($i == $page) {
                // No mostramos un vínculo para la página actual
                    echo($i . " ");
                } else {
                    echo "<a href=MantHardwareInventory.php?pagina=$i>$i</a> ";
                }
            }
            if(($total % $limite) != 0) {
                if($i == $page) {
                    echo($i. " ");
                } else {
                    echo "<a href=MantHardwareInventory.php?pagina=$i>$i</a> ";
                }
            }
            if(($total - ($limite * $pagina)) > 0) {
 
                $pagina_siguiente = $pagina+1;
                echo "<a href=MantHardwareInventory.php?pagina=$pagina_siguiente> Next </a>";
 
            } else {
 
                echo "Next";
 
 
            }
 
 
            // La siguiente línea no es realmente necesaria porque MySQL libera los resultados
            // luego de que el último script se ha ejecutado.
            //  mysql_free_result($result);
            ?>
 
 
            <table class="tbl" border="1" cellspacing="1" cellpadding="1" width="90%" style="font-size: 8pt; color: black">
 
 
 
                <tr  align="center" style="font-size: 11pt; color: blue">
 
                    <td>&nbsp;PC card</td>
                    <td>&nbsp;Plant&nbsp;</td>
                    <td>&nbsp;Department&nbsp;</td>
                    <td>&nbsp;User Name&nbsp;</td>
                    <td>&nbsp;PC card monitor</td>
                    <td>&nbsp;Procesor speed</td>
                    <td>&nbsp;Model Number</td>
                    <td>&nbsp;PC name</td>
                    <td>&nbsp;Operating System</td>
                    <td>&nbsp;Office version</td>
                    <td>&nbsp;RAM memory</td>
                    <td>&nbsp;View</td>
                    <td>&nbsp;Edit</td>
                    <td>&nbsp;Delete</td>
                    <td>&nbsp;Print</td>
 
                </tr>
 
 
                <?php
 
                while($row = mysql_fetch_array($result)) {
 
                    ?>
 
                <tr>
 
                    <td ><?php echo htmlspecialchars($row["0"]) ?></td>
                    <td ><?php echo htmlspecialchars($row["1"]) ?></td>
                    <td ><?php echo htmlspecialchars($row["2"]) ?></td>
                    <td ><?php echo htmlspecialchars($row["3"]) ?></td>
                    <td ><?php echo htmlspecialchars($row["4"]) ?></td>
                    <td ><?php echo htmlspecialchars($row["5"]) ?></td>
                    <td ><?php echo htmlspecialchars($row["6"]) ?></td>
                    <td ><?php echo htmlspecialchars($row["7"]) ?></td>
                    <td ><?php echo htmlspecialchars($row["8"]) ?></td>
                    <td ><?php echo htmlspecialchars($row["9"]) ?></td>
                    <td ><?php echo htmlspecialchars($row["10"]) ?></td>
                    <td ><a href="ViewRecords.php?a=view&id=<?php echo $row["0"] ?>&pg=<?php echo $pagina ?>"><img src="image/view.bmp"></a></td>
                    <td ><a href="UpdateTable.php?a=edit&id=<?php echo $row["0"]?>"><img src="image/edit.bmp"></a></td>
                    <td ><a href="delete.php?a=del&id=<?php echo $row["0"] ?>"><img src="image/delete.bmp"></a> </td>
                    <td ><a href="Pc_card_Report.php?a=del&id=<?php echo $row["0"] ?>&plant=<?php echo $row["1"] ?>&deparment=<?php echo $row["2"] ?>&username=<?php echo $row["3"] ?>&pccardm=<?php echo $row["4"] ?>&procespeed=<?php echo $row["5"] ?>&modeln=<?php echo $row["6"] ?>&pcname=<?php echo $row["7"] ?>&oprsys=<?php echo $row["8"] ?>"><img src="image/print.ico"></a></td>
                </tr>
                <?php
 
                }
 
                ?>
            </table>
 
 
 
 
        </form>
    </body>
</html>