PHP Help Please
4 posts
Page 1 of 1
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.
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> </TD><TD>".$myrow["paydate"]." </TD><TD>£".$strmoney." </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> </td>
<td></td>
<td></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>TOTAL MONEY DUE</td>
<td>£<?=number_format($totmoney, 2);?> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<br />
</body>
</head>
</html>
</div>
<?php
}
?>
<?php require("./styles/bottom.php"); ?>
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.
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.
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:
-Filip
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
KR,SELECT * FROM `customers` WHERE `paydate` > NOW() AND `asap` = 0
-Filip
CodenStuff wrote:Nope, it's just your sick and dirty mind. You sick twisted warped little pervo![]()
4 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023