Activity Stream
48,167 MEMBERS
6793 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1.     
    #1
    Member
    Website's:
    heroturko.biz softpk.com gfxtra.biz hotfilegfx.com

    Default i 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

  2.   Sponsored Links

  3.     
    #2
    Respected 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>"
                                            } 
    to 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>"
                                           
    $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>"
                                            } 

  4.     
    #3
    Member
    Website's:
    heroturko.biz softpk.com gfxtra.biz hotfilegfx.com
    no 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>"

  5.     
    #4
    Respected Member
    Hard when you can't test it. I am surprised got that far.
    from
    PHP Code: 
    echo "<td>" $colorPrefix $date $colorSuffix ."</td>"
    to
    PHP Code: 
    echo "<td>" $colorPrefix $date->format("m-d-Y") . $colorSuffix ."</td>"

  6.     
    #5
    Member
    Website's:
    heroturko.biz softpk.com gfxtra.biz hotfilegfx.com
    This code is working thank you

    The color can be changed on the whole row? PPM Due Date is just the text color is changed

  7.     
    #6
    You 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>";  
                                            } 
    in your CSS, for instance to change the background of the row to red, something along the lines of:

    PHP Code: 
    .expireWarn {
        
    background-colorred;
        
    color#fff;

    Feel free to play around with the font/background colors

    Regards,
    Gaurav



    My Langotiya Yaars (Chaddi buddies): JmZ, humour, Chutad, Esotorisk, l0calhost, Daniel, Mind Freak?, TLK, Amz

  8.     
    #7
    Member
    Website's:
    heroturko.biz softpk.com gfxtra.biz hotfilegfx.com
    sir 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>";
                                            } 


  9.     
    #8
    You 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>"
    to

    PHP Code: 
    echo "<td>" $date->format("m-d-Y") . "</td>"
    Regards



    My Langotiya Yaars (Chaddi buddies): JmZ, humour, Chutad, Esotorisk, l0calhost, Daniel, Mind Freak?, TLK, Amz

  10.     
    #9
    Respected Member
    Quote Originally Posted by softpk View Post
    This code is working thank you

    The color can be changed on the whole row? PPM Due Date is just the text color is changed
    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>"
    to
    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

  11.     
    #10
    Member
    Website's:
    heroturko.biz softpk.com gfxtra.biz hotfilegfx.com
    sir i want to change whole row background color is red not only text

    like this:


Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Selling] Excellent Matrimonial Script| Complete readymade Matrimony Script Available
    By matriscript4u in forum Marketplace (Buy, Sell and Trade)
    Replies: 0
    Last Post: 23rd Oct 2012, 02:54 PM
  2. Replies: 12
    Last Post: 13th Mar 2012, 02:23 PM
  3. Greasemonkey script: Megaupload Premium Multifetch Script
    By Dman in forum Webmaster Resources
    Replies: 46
    Last Post: 15th Dec 2011, 01:07 AM
  4. [Selling] Rslinkgens Premium link generator script V1 -Most advanced and viral script
    By vccshopper in forum Completed Transactions
    Replies: 0
    Last Post: 24th Jun 2011, 08:10 PM
  5. [Selling] A.A.S. (Adult Automated Script For ClipBucket Video Script)
    By tangi in forum Completed Transactions
    Replies: 0
    Last Post: 25th Mar 2011, 12:45 PM

Tags for this Thread

BE SOCIAL