Results 1 to 10 of 13
-
25th Feb 2012, 10:14 PM #1OPMemberWebsite's:
heroturko.biz softpk.com gfxtra.biz hotfilegfx.comi need help php and sql script
I am making in this database should help me see my database images
PPM Due Date in the day, as it becomes red in the table.
like: today date is: 28-02-2012, today agha khan product is expire to auto change color this table
and i want to change date format like: D-M-Y please help me
my database code is:
PHP Code:<?php
// connect to the database
include('connect-db.php');
// get the records from the database
if ($result = $mysqli->query("SELECT * FROM insrep ORDER BY id"))
{
// display records if there are records to display
if ($result->num_rows > 0)
{
// display records in a table
echo "<div class='mws-panel grid_8'>";
echo "<div class='mws-panel-header'><span class='mws-i-24 i-table-1'>Installation Report</span></div>";
echo "<div class='mws-panel-body'>";
echo "<table class='mws-datatable mws-table'>";
// set table headers
echo "<thead><tr><th>Date</th><th>Service Report No</th><th>Hospital Name</th><th>Description</th><th>Model No</th><th>Serial No</th><th>Date of Installation</th><th>PPM Due date</th><th>Warranty</th></tr></thead>";
while ($row = $result->fetch_object())
{
// set up a row for each record
echo "<tr class='gradeX'>";
echo "<td>" . $row->dateinsrep . "</td>";
echo "<td>" . $row->servicereport . "</td>";
echo "<td>" . $row->hospitalname . "</td>";
echo "<td>" . $row->description . "</td>";
echo "<td>" . $row->model . "</td>";
echo "<td>" . $row->serial . "</td>";
echo "<td>" . $row->dinstall . "</td>";
echo "<td>" . $row->ppmduedate . "</td>";
echo "<td>" . $row->warranty . "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo "</div>";
echo "</div>";
}
// if there are no records in the database, display an alert message
else
{
echo "No results to display!";
}
}
// show an error if there is an issue with the database query
else
{
echo "Error: " . $mysqli->error;
}
// close database connection
$mysqli->close();
?>softpk Reviewed by softpk on . i need help php and sql script I am making in this database should help me see my database images http://vvcap.net/db/KWBZVLTBV8XJYL-0YKBb.png PPM Due Date in the day, as it becomes red in the table. like: today date is: 28-02-2012, today agha khan product is expire to auto change color this table and i want to change date format like: D-M-Y please help me Rating: 5
-
25th Feb 2012, 11:47 PM #2Respected Member
Not sure of your actual database bits & bytes but this should work or give you a good head start.
change this
PHP Code:echo "<thead><tr><th>Date</th><th>Service Report No</th><th>Hospital Name</th><th>Description</th><th>Model No</th><th>Serial No</th><th>Date of Installation</th><th>PPM Due date</th><th>Warranty</th></tr></thead>";
while ($row = $result->fetch_object())
{
// set up a row for each record
echo "<tr class='gradeX'>";
echo "<td>" . $row->dateinsrep . "</td>";
echo "<td>" . $row->servicereport . "</td>";
echo "<td>" . $row->hospitalname . "</td>";
echo "<td>" . $row->description . "</td>";
echo "<td>" . $row->model . "</td>";
echo "<td>" . $row->serial . "</td>";
echo "<td>" . $row->dinstall . "</td>";
echo "<td>" . $row->ppmduedate . "</td>";
echo "<td>" . $row->warranty . "</td>";
echo "</tr>";
}
PHP Code:echo "<thead><tr><th>Date</th><th>Service Report No</th><th>Hospital Name</th><th>Description</th><th>Model No</th><th>Serial No</th><th>Date of Installation</th><th>PPM Due date</th><th>Warranty</th></tr></thead>";
$today = new DateTime("now");
while ($row = $result->fetch_object())
{
$colorPrefix = '';
$colorSuffix = '';
$date = new DateTime($row->ppmduedate);
if ($today >= $date) {$colorPrefix = '<font color="red">'; $colorSuffix = '</font>';}
$due = $date->format("m-d-Y");
// set up a row for each record
echo "<tr class='gradeX'>";
echo "<td>" . $row->dateinsrep . "</td>";
echo "<td>" . $row->servicereport . "</td>";
echo "<td>" . $row->hospitalname . "</td>";
echo "<td>" . $row->description . "</td>";
echo "<td>" . $row->model . "</td>";
echo "<td>" . $row->serial . "</td>";
echo "<td>" . $row->dinstall . "</td>";
echo "<td>" . $colorPrefix . $date . $colorSuffix ."</td>";
echo "<td>" . $row->warranty . "</td>";
echo "</tr>";
}
-
26th Feb 2012, 01:36 AM #3OPMemberWebsite's:
heroturko.biz softpk.com gfxtra.biz hotfilegfx.comno sir this code is not work show this error
Catchable fatal error: Object of class DateTime could not be converted to string in G:\WampDeveloper\Websites\DefaultWebsite\webroot\d atabase\ins-view.php on line 445
and 445 line is:
PHP Code:echo "<td>" . $colorPrefix . $date . $colorSuffix ."</td>";
-
26th Feb 2012, 01:52 AM #4Respected Member
Hard when you can't test it. I am surprised got that far.
from
PHP Code:echo "<td>" . $colorPrefix . $date . $colorSuffix ."</td>";
PHP Code:echo "<td>" . $colorPrefix . $date->format("m-d-Y") . $colorSuffix ."</td>";
-
26th Feb 2012, 02:51 AM #5OPMemberWebsite's:
heroturko.biz softpk.com gfxtra.biz hotfilegfx.comThis code is working thank you
The color can be changed on the whole row? PPM Due Date is just the text color is changed
-
26th Feb 2012, 08:31 AM #6You can call me G
just assign a class to the table row in case $today >= $date and style it the way you want in the stylesheet.
PHP Code:echo "<thead><tr><th>Date</th><th>Service Report No</th><th>Hospital Name</th><th>Description</th><th>Model No</th><th>Serial No</th><th>Date of Installation</th><th>PPM Due date</th><th>Warranty</th></tr></thead>";
$today = new DateTime("now");
while ($row = $result->fetch_object())
{
$bgclass = "gradeX ";
$date = new DateTime($row->ppmduedate);
if ($today >= $date) {$bgclass = "expireWarn"}
$due = $date->format("m-d-Y");
// set up a row for each record
echo "<tr class=$bgclass>";
echo "<td>" . $row->dateinsrep . "</td>";
echo "<td>" . $row->servicereport . "</td>";
echo "<td>" . $row->hospitalname . "</td>";
echo "<td>" . $row->description . "</td>";
echo "<td>" . $row->model . "</td>";
echo "<td>" . $row->serial . "</td>";
echo "<td>" . $row->dinstall . "</td>";
echo "<td>" . $date ."</td>";
echo "<td>" . $row->warranty . "</td>";
echo "</tr>";
}
PHP Code:.expireWarn {
background-color: red;
color: #fff;
}
Regards,
Gaurav
My Langotiya Yaars (Chaddi buddies): JmZ, humour, Chutad, Esotorisk, l0calhost, Daniel, Mind Freak?, TLK, Amz
-
26th Feb 2012, 11:53 AM #7OPMemberWebsite's:
heroturko.biz softpk.com gfxtra.biz hotfilegfx.comsir no this code is not work show this error
Catchable fatal error: Object of class DateTime could not be converted to string in G:\WampDeveloper\Websites\DefaultWebsite\webroot\d atabase\ins-view.php on line 455
455 Line is:
// set up a row for each record
echo "<tr class=$bgclass>";
and i am using code
PHP Code:$today = new DateTime("now");
// display records in a table
echo "<div class='mws-panel grid_8'>";
echo "<div class='mws-panel-header'><span class='mws-i-24 i-table-1'>Installation Report</span></div>";
echo "<div class='mws-panel-body'>";
echo "<table class='mws-datatable mws-table' id='example'>";
// set table headers
echo "<thead><tr><th>Date</th><th>Service Report No</th><th>Hospital Name</th><th>Description</th><th>Model No</th><th>Serial No</th><th>Date of Installation</th><th>PPM Due date</th><th>Warranty</th></tr></thead>";
while ($row = $result->fetch_object())
{
$bgclass = "gradeX";
$colorPrefix = '';
$colorSuffix = '';
$dateinsrep = new DateTime($row->dateinsrep);
$dinstall = new DateTime($row->dinstall);
$date = new DateTime($row->ppmduedate);
if ($today >= $date) {$bgclass = "expireWarn";}
$due = $date->format("d-m-Y");
$due = $dateinsrep->format("d-m-Y");
$due = $dinstall->format("d-m-Y");
// set up a row for each record
echo "<tr class=$bgclass>";
echo "<td>" . $dateinsrep->format("d-m-Y") . "</td>";
echo "<td>" . $row->servicereport . "</td>";
echo "<td>" . $row->hospitalname . "</td>";
echo "<td>" . $row->description . "</td>";
echo "<td>" . $row->model . "</td>";
echo "<td>" . $row->serial . "</td>";
echo "<td>" . $dinstall->format("d-m-Y") . "</td>";
echo "<td>" . $date . "</td>";
echo "<td>" . $row->warranty . "</td>";
echo "</tr>";
}
-
26th Feb 2012, 01:56 PM #8You can call me G
My bad.. looks like Lock Down hadn't edited his post after the correction..
change
PHP Code:echo "<td>" . $date . "</td>";
PHP Code:echo "<td>" . $date->format("m-d-Y") . "</td>";
My Langotiya Yaars (Chaddi buddies): JmZ, humour, Chutad, Esotorisk, l0calhost, Daniel, Mind Freak?, TLK, Amz
-
26th Feb 2012, 02:55 PM #9Respected Member
You are welcome..
For the text in the whole row..
change
PHP Code:echo " <td>" . $row->dateinsrep . "</td>";
echo "<td>" . $row->servicereport . "</td>";
echo "<td>" . $row->hospitalname . "</td>";
echo "<td>" . $row->description . "</td>";
echo "<td>" . $row->model . "</td>";
echo "<td>" . $row->serial . "</td>";
echo "<td>" . $row->dinstall . "</td>";
echo "<td>" .$date ."</td>";
echo "<td>" . $row->warranty . "</td>";
PHP Code:echo $colorPrefix . " <td>" . $row->dateinsrep . "</td>";
echo "<td>" . $row->servicereport . "</td>";
echo "<td>" . $row->hospitalname . "</td>";
echo "<td>" . $row->description . "</td>";
echo "<td>" . $row->model . "</td>";
echo "<td>" . $row->serial . "</td>";
echo "<td>" . $row->dinstall . "</td>";
echo "<td>" .$date ."</td>";
echo "<td>" . $row->warranty . "</td>". $colorSuffix;
-
26th Feb 2012, 04:10 PM #10OPMemberWebsite's:
heroturko.biz softpk.com gfxtra.biz hotfilegfx.comsir i want to change whole row background color is red not only text
like this:
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
[Selling] Excellent Matrimonial Script| Complete readymade Matrimony Script Available
By matriscript4u in forum Marketplace (Buy, Sell and Trade)Replies: 0Last Post: 23rd Oct 2012, 02:54 PM -
[Selling] Mp3 Search Engine, File Host, SMS Script, Arcade Script, PDF Search Script, and More!
By Fileze in forum Completed TransactionsReplies: 12Last Post: 13th Mar 2012, 02:23 PM -
Greasemonkey script: Megaupload Premium Multifetch Script
By Dman in forum Webmaster ResourcesReplies: 46Last Post: 15th Dec 2011, 01:07 AM -
[Selling] Rslinkgens Premium link generator script V1 -Most advanced and viral script
By vccshopper in forum Completed TransactionsReplies: 0Last Post: 24th Jun 2011, 08:10 PM -
[Selling] A.A.S. (Adult Automated Script For ClipBucket Video Script)
By tangi in forum Completed TransactionsReplies: 0Last Post: 25th Mar 2011, 12:45 PM
themaLeecher - leech and manage...
Version 5.03 released. Open older version (or...