• Top Members
    Reps
    Posts
  • 834 Replies
    2585 Replies
  • 716 Replies
    2025 Replies
  • 331 Replies
    1928 Replies

PHP Help Please

User avatar
Mark
VIP - Donator
Posts: 370

PHP Help Please

Wed Mar 16, 2016 5:55 pm

Hello,

this is my code below is displays all my records on the page i was wondering if someone can help me please i have a field in mysql called payday it shows the date they are ment to pay me but if there late as paying i was it to display the records that have asap on not the one's with the dates can anyone help me please this is the code.

Code: Select all

<?php 
session_start();
require("./styles/top.php"); ?>

<?php
if(!isset($_SESSION['session_user'])) {
    echo("You must be logged in to view this page!.");
} else {
?>

<html>
<head>
<style>
table, td, th{
    border:  1px solid black;
}

td {
    padding:  5px;
}
</style>

<div id="full">
<body>
    <p>Welcome, <?=$_SESSION['session_user']; ?> | <a href="logout.php">Logout</a> <br /> <br /> <button onclick="window.location.href='_add.php'">Add New Order</button>  <button onclick="window.location.href='today.php'">Check If Money Is Due</button> <button onclick="window.location.href='asap.php'">Check All ASAP Money Due In</button></p><hr />
			<table class="viewtable">
				<tr>
					<td>FULL NAME </td>
					<td>PAY DATE</td>
					<td>MONEY DUE</td>
					<td id="toolbar">VIEW</td>
					<td id="toolbar0">EDIT</td>
					<td id="toolbar1">DELETE</td>
				</tr>
                
                <?php
                
                error_reporting(0);
                $sql = mysql_connect("", "", "") or die (mysql_error());
                $select_db = mysql_select_db("", $sql);
                $result = mysql_query("SELECT * FROM customers", $sql);
            
                
                $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["name"]."</A>&nbsp;</TD><TD>".$myrow["paydate"]."&nbsp;</TD><TD>&pound;".$strmoney."&nbsp;</TD>";
                    echo "<TD><a href=\"_view.php?id=".$myrow['id']."\"><img class=\"displayed\" alt=\"View\" src=\"images/view.png\" width=\"16\" height=\"16\" /></a></TD>";
				    echo "<TD><a href=\"_edit.php?id=".$myrow['id']."\"><img class=\"displayed\" alt=\"View\" src=\"images/edit.png\" width=\"16\" height=\"16\" /></a></TD>";
    				echo "<TD><a href=\"_delete.php?id=".$myrow['id']."\"><img class=\"displayed\" alt=\"View\" src=\"images/delete.png\" width=\"16\" height=\"16\" /></a></TD>";
    				echo "</TR>";
                    
                    $totmoney = $totmoney + (int)$myrow["money"];
                }
                
                ?>
                
                   <tr>
						<td>&nbsp;</td>
						<td></td>
						<td></td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
					</tr>
                
                <tr>
						<td>&nbsp;</td>
						<td>TOTAL MONEY DUE</td>
						<td>&pound;<?=number_format($totmoney, 2);?>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
					</tr>
              			
			</table>
            <br />   
            
            
            
            
</body>
</head>
</html>




</div>

<?php
}
?>


<?php require("./styles/bottom.php"); ?>

User avatar
CodenStuff
Site Admin
Posts: 4373

Re: PHP Help Please

Thu Mar 17, 2016 12:28 pm

Yet again I'm not entirely sure what it is you're asking for but I'm guessing you only want to display records of people who are late on their payments?

Could you not simply using a date function in your query to compare the PAYDATE with TODAY, if PAYDATE (is less than) TODAY then the payment is late and select that record.

I found loads of examples here: http://stackoverflow.com/questions/5182 ... y-in-mysql

Hopefully that should help if this is what you're trying to accomplish and they have lots of answers dependent on how you're storing the date/time values.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.

User avatar
Mark
VIP - Donator
Posts: 370

Re: PHP Help Please

Thu Mar 17, 2016 12:45 pm

Hello,

Thanks Cody for your reply.

I have attached a screenshot for you to see what i mean it says the date and some say asap i dont want to display the ones with asap i only want to show the records with the date provided?

Image

User avatar
Filip
Coding Guru
Posts: 833

Re: PHP Help Please

Fri Mar 18, 2016 11:17 am

Hey,

If I was you, I'd add another column with into the table named asap in type of bool or tinyint(1). When you have row type as timestamp, it's much more easier to build queries that are time related.

If you implemented that, you'd want to do a query like this:

Code: Select all

SELECT * FROM `customers` WHERE `paydate` > NOW() AND `asap` = 0
KR,
-Filip
CodenStuff wrote:Nope, it's just your sick and dirty mind. You sick twisted warped little pervo :D

Post Reply

Return to “Help & Support”