Pagination Help

1 post Page 1 of 1
Contributors
User avatar
Mark
VIP - Donator
VIP - Donator
Posts: 372
Joined: Mon Aug 17, 2009 10:35 pm

Pagination Help
Mark
Hello,

I am having problems with my pagination code when i add a WHERE clause in it it wont display any records like the following code
Code: Select all
<?php include('styles/top.php'); ?>


    
     <div id="full">
    
        <div id="view_box">
            <ul>
                <li><img src="images/1.png" /></li>
                <!-- <li><img src="pics/2.jpg" /></li> -->
                <!-- <li><img src="pics/3.jpg" /></li> -->
            </ul>
        </div>
        
        <div id="button">
            <ul>
                <!-- <li><button class="button" scroll_value="0">*</button></li> -- >
                <!-- <li><button class="button" scroll_value="600">*</button></li> -->
                <!-- <li><button class="button" scroll_value="1200">*</button></li> -->
            </ul>
        </div>
        <hr /><br />
        
       <?php
        
        if (($user_level !=1) && ($user_level !=2)){
            echo "No Access Allowed";
        } else {
        
        $per_page = 5;
        $pages_query = mysql_query("SELECT COUNT(`id`) FROM(`orders`) WHERE OrderBy = '$username'");
        $pages = ceil(mysql_result($pages_query,0)/$per_page);
        
        if (!isset($_GET['page']))
        {
            echo "<meta http-equiv='refresh' content='0;url=view.php?page=1'>";
        }
        else
        {
            $page = $_GET['page'];
        }
        
        $start = (($page - 1)*$per_page);
        
        for ($number=1;$number<=$pages;$number++)
        {
            echo '<a href="?page='.$number.'">'.$number.'</a>';
        }
            echo "<br/><br/>Current Page: $page ";
        ?>
        
        <h3>View Orders</h3>
        
        		<table border=1">
				<tr>
					<th>FULL NAME </th>
                    <th>DATE GOT </th>
					<th>PAY DATE</th>
					<th>MONEY DUE</th>
                    <th>UPDATE ORDER STATUS</th>
				</tr>
                
                <tr>
						<td>&nbsp;</td>
						<td></td>
						<td></td>
                        <td></td>
                        <td></td>
					</tr>
                
                <?php
                
                error_reporting(0);
                $result = mysql_query("SELECT * FROM orders LIMIT $start,$per_page WHERE OrderBy = '$username'");
            
                
                $totmoney = 0;
                $strmoney = "";
                
                while ($myrow = mysql_fetch_array($result))
                {
                    $strmoney = $myrow["Money"];
                    $strmoney = str_replace(',','',$strmoney);
                    
                    if(is_numeric($strmoney))
                    {
                        settype($strmoney, "float");
                        $strmoney = number_format($strmoney, 2);
                    }
                    echo "<TR><TD><a href=\"_view.php?id=".$myrow['id']."\">".$myrow["FullName"]."</A>&nbsp;</TD><TD>".$myrow["GotDate"]."&nbsp;</TD><TD>".$myrow["PayDate"]."&nbsp;</TD><TD>&pound;".$strmoney."&nbsp;</TD>";
    				echo "<TD><center><a href=\"update_order.php?id=".$myrow['id']."\"><img class=\"displayed\" alt=\"View\" src=\"images/edit.png\" width=\"175\" height=\"25\" /></a></center></TD>";
                    echo "</TR>";
                    
                    $totmoney = $totmoney + (int)$myrow["Money"];
                }
                
                
                ?>
                
                
                   <tr>
						<td>&nbsp;</td>
						<td></td>
						<td></td>
                        <td></td>
                        <td></td>
					</tr>
                
                <tr>
						<td>&nbsp;</td>
						<td>TOTAL DUE</td>
						<td>&pound;<?=number_format($totmoney, 2);?>&nbsp;</td>
                        <td></td>
                        <td></td>
					</tr>
              			
			</table>
            
            
            <br />  
       
             
               
        <?php
        }
        ?>
        
        
       
    </div>

<?php include('styles/bottom.php'); ?>
But if i do it all like this it displays the records to everyone not only the records that they placed them selfs.
Code: Select all
<?php include('styles/top.php'); ?>


    
     <div id="full">
    
        <div id="view_box">
            <ul>
                <li><img src="images/1.png" /></li>
                <!-- <li><img src="pics/2.jpg" /></li> -->
                <!-- <li><img src="pics/3.jpg" /></li> -->
            </ul>
        </div>
        
        <div id="button">
            <ul>
                <!-- <li><button class="button" scroll_value="0">*</button></li> -- >
                <!-- <li><button class="button" scroll_value="600">*</button></li> -->
                <!-- <li><button class="button" scroll_value="1200">*</button></li> -->
            </ul>
        </div>
        <hr /><br />
        
       <?php
        
        if (($user_level !=1) && ($user_level !=2)){
            echo "No Access Allowed";
        } else {
        
        $per_page = 5;
        $pages_query = mysql_query("SELECT COUNT(`id`) FROM(`orders`) WHERE OrderBy = '$username'");
        $pages = ceil(mysql_result($pages_query,0)/$per_page);
        
        if (!isset($_GET['page']))
        {
            echo "<meta http-equiv='refresh' content='0;url=view.php?page=1'>";
        }
        else
        {
            $page = $_GET['page'];
        }
        
        $start = (($page - 1)*$per_page);
        
        for ($number=1;$number<=$pages;$number++)
        {
            echo '<a href="?page='.$number.'">'.$number.'</a>';
        }
            echo "<br/><br/>Current Page: $page ";
        ?>
        
        <h3>View Orders</h3>
        
        		<table border=1">
				<tr>
					<th>FULL NAME </th>
                    <th>DATE GOT </th>
					<th>PAY DATE</th>
					<th>MONEY DUE</th>
                    <th>UPDATE ORDER STATUS</th>
				</tr>
                
                <tr>
						<td>&nbsp;</td>
						<td></td>
						<td></td>
                        <td></td>
                        <td></td>
					</tr>
                
                <?php
                
                error_reporting(0);
                $result = mysql_query("SELECT * FROM orders LIMIT $start,$per_page WHERE OrderBy = '$username'");
            
                
                $totmoney = 0;
                $strmoney = "";
                
                while ($myrow = mysql_fetch_array($result))
                {
                    $strmoney = $myrow["Money"];
                    $strmoney = str_replace(',','',$strmoney);
                    
                    if(is_numeric($strmoney))
                    {
                        settype($strmoney, "float");
                        $strmoney = number_format($strmoney, 2);
                    }
                    echo "<TR><TD><a href=\"_view.php?id=".$myrow['id']."\">".$myrow["FullName"]."</A>&nbsp;</TD><TD>".$myrow["GotDate"]."&nbsp;</TD><TD>".$myrow["PayDate"]."&nbsp;</TD><TD>&pound;".$strmoney."&nbsp;</TD>";
    				echo "<TD><center><a href=\"update_order.php?id=".$myrow['id']."\"><img class=\"displayed\" alt=\"View\" src=\"images/edit.png\" width=\"175\" height=\"25\" /></a></center></TD>";
                    echo "</TR>";
                    
                    $totmoney = $totmoney + (int)$myrow["Money"];
                }
                
                
                ?>
                
                
                   <tr>
						<td>&nbsp;</td>
						<td></td>
						<td></td>
                        <td></td>
                        <td></td>
					</tr>
                
                <tr>
						<td>&nbsp;</td>
						<td>TOTAL DUE</td>
						<td>&pound;<?=number_format($totmoney, 2);?>&nbsp;</td>
                        <td></td>
                        <td></td>
					</tr>
              			
			</table>
            
            
            <br />  
       
             
               
        <?php
        }
        ?>
        
        
       
    </div>

<?php include('styles/bottom.php'); ?>
http://www.mbappz.com
1 post Page 1 of 1
Return to “Help & Support”