Hello Guys,
Im having problems with my code when i add a new record to my mysqli database its svaing the record but isnt displaying the new one it then duplicates the 2nd newest record can anyone help please?.
Its only showing 38 records when it should display 39 as thats whats in the database
<?php include('styles/top.php'); ?>
<div id="left">
<?php
if ($user_level !=1){
} else {
include("css/menu.php");
?>
<?php
}
?>
</div>
<div id="right">
<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 />
<?php
if ($user_level !=1){
echo "No Access Allowed Admin Only ";
} else {
if(isset($_GET['page'])){
$page = $_GET['page'];
} else {
$page = 1;
}
if($page == '' || $page == 1){
$page1 = 0;
} else {
$page1 = ($page*4)-4;
}
$sql = 'SELECT * FROM customers LIMIT '.$page1.', 4';
$data = $con->query($sql);
?>
<h3>CURRENT CUSTOMERS</h3>
<table border=1">
<tr>
<th>CUSTOMER NAME </th>
<th>ACCOUNT STATUS</th>
<th>UPDATE</th>
<th>DELETE</th>
</tr>
<tr>
<td> </td>
<td></td>
<td></td>
<td></td>
</tr>
<?php
while ($myrow = mysqli_fetch_array($data))
{
echo "<TR>
<TD>".$myrow["customer_name"]."</TD>
<TD>".$myrow["type"]."</TD>";
echo "<TD>
<a href=\"update_edit_customer.php?id=".$myrow['id']."\">UPDATE</a>
</TD>";
echo "<TD>
<a href=\"delete-customer.php?id=".$myrow['id']."\">DELETE</a>
</TD>";
echo "</TR>";
}
?>
<tr>
<td> </td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<br />
<?php
$sql = "SELECT * FROM customers";
$data = $con->query($sql);
$records = $data->num_rows;
$records_pages = $records/4;
$records_pages = ceil($records_pages);
$prev = $page-1;
$next = $page+1;
echo '<ul class="paganation">';
if($prev >= 5){
echo '<li><a href="?page=1">First Page</a></li>';
}
if($prev >=1){
echo '<li><a href="?page='.$prev.'">Previous</a></li>';
}
if($records_pages >= 2 ){
for($r=1; $r <= $records_pages; $r++){
$active = $r == $page ? 'class="active"' : '';
echo '<li><a href="?page='.$r.'" '.$active.'>'.$r.'</a></li>';
}
}
if($next <= $records_pages && $records_pages >= 2){
echo '<li><a href="?page='.$next.'">Next</a></li>';
}
if($page != $records_pages && $records_pages >= 5){
echo '<li><a href="?page='.$records_pages.'">Last Page</a></li>';
}
echo '</ul>';
?>
<?php
}
?>
</div>
<?php include('styles/bottom.php'); ?>