-
Oct 26th, 2024, 05:00 AM
#1
Thread Starter
New Member
PayDate
Hello Guys,
I'm using this code to show all orders that have been placed in the database, my question is i was wondering how i can go about getting to show by the earliest day so for example i have 3 records like 29/10/2024 and 23/10/2024 and 27/10/2024 and the field in the mysqli database is called PayDate show do i get it to show the dates like the above but in order using the code below.
PHP Code:
<?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
//error_reporting(0);
if (($user_level !=1) && ($user_level !=2)){
echo "No Access Allowed";
} 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 orders Where orderby= '$username' AND Status='paid' LIMIT ".$page1.", 4";
//$sql = 'SELECT * FROM orders LIMIT '.$page1.', 4';
$data = $con->query($sql);
?>
<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> </td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<?php
$totmoney = 0;
$strmoney = "";
while ($myrow = mysqli_fetch_array($data))
{
$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> </TD><TD>".$myrow["GotDate"]." </TD><TD>".$myrow["PayDate"]." </TD><TD>£".$strmoney." </TD>";
echo "<TD><center><a href=\"edit_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> </td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td> </td>
<td>TOTAL DUE</td>
<td>£<?=number_format($totmoney, 2);?> </td>
<td></td>
<td></td>
</tr>
</table>
<br />
<?php
$sql = "SELECT * FROM orders Where orderby= '$username' AND Status='Layon'";
$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'); ?>
-
Oct 26th, 2024, 11:09 AM
#2
Re: PayDate
Add an ORDER BY PayDate to your sql query
-tg
-
Oct 29th, 2024, 02:27 PM
#3
Thread Starter
New Member
Re: PayDate
hello ive tried
Code:
$sql = "SELECT * FROM orders Where ORDER BY paydate customer_name= '$customer_name' AND Status='paid' LIMIT ".$page1.", 4";
all the records remove from the page.
also i have said my field in the mysqli database is a VARCHAR(50) and used the date format like
29/10/2024
-
Oct 30th, 2024, 02:10 AM
#4
Re: PayDate
*sigh*
Learn SQL
Spot the Mistake
Code:
SELECT * FROM orders Where ORDER BY paydate customer_name= '$customer_name' AND
SELECT SomeFields
FROM FromTable
WHERE Condition
ORDER BY OrderingColumns
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Oct 30th, 2024, 08:04 AM
#5
Re: PayDate
Still not going to sort right because
my field in the mysqli database is a VARCHAR(50) and used the date format like
29/10/2024
(cries in DATETIME fields)
-tg
-
Oct 30th, 2024, 08:25 AM
#6
Re: PayDate
Originally Posted by techgnome
Still not going to sort right because
(cries in DATETIME fields)
-tg
Didn't even see that one....
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|