July 31, 2012

How to get date from the datetime in php

How to get date from the datetime in php


$result = mysql_query("SELECT `datetime` FROM `table`");
$row = mysql_fetch_row($result);
$date = date_create($row[0]);

echo date_format($date, 'Y-m-d H:i:s');

echo date_format($date, 'd/m/Y H:i:s');

echo date_format($date, 'd/m/y');

echo date_format($date, 'g:i A');

echo date_format($date, 'G:ia');

echo date_format($date, 'g:ia \o\n l jS F Y');

July 28, 2012

How To Get Month Number to Month Name in PHP


<?php
$monthNum = 5;
$monthName = date("F", mktime(0, 0, 0, $monthNum, 10));
echo $monthName;
?>
//output: May

July 25, 2012

Select query to get total # records for each day in a month

select day(DateField), count(*) from table where month(DateField) = month(NOW()) and year(DateField) = year(NOW()) group by day(DateField)

February 2, 2011

HOW UPDATE THE RECORDS IN THE DATABASE

//first get the record in the text box then follow the code..........and see in class file.
<?php  
    include("../config/connection.php");
    include("../template/tmp_menu.php");
    if(isset($_REQUEST['save']))
    {  
        include("../class/user.class.php");
        $o_u=new User();
        $_record = array('name'=>$pro_name,'quentity'=>$pro_quentity,'rate'=>$pro_rate);
        $o_q = $o_u->AddRecord('product',$_record);
        $i_up = $o_u -> Uploadimages();
        print "<META http-equiv='refresh' content='0;URL=../template/tmp_product.php'>";      
    }
 ?>
<html>
<head>
</head>
<body>
<form method="post" enctype="multipart/form-data">
    <table>
        <tr>
            <td>Name:</td>
            <td><input type="text" name="pro_name" ></td>
        </tr>
        <tr>
            <td>Quentity:</td>
            <td><input type="text" name="pro_quentity" ></td>
        </tr>
        <tr>
            <td>Rate:</td>
            <td><input type="text" name="pro_rate" ></td>
        </tr>
        <tr>
            <td><input type="submit" name="save" value="save"></td>
        </tr>
    </table>
</form>
</body>
</html>


------------------------------------------------------------------------------------------------------------
 
//this is the class file...
<?php
class User
{

   public function SelectRecord($table,$field)
    {
        $qr = "select * from $table where id_$table = '$field'";
        $o__user = mysql_query($qr);
        return $o__user;
    }
    //update records.
    public function UpdateRecord($table,$field,$id)
    {
        $qr= "update $table set ";
        foreach($field as $key => $value)
        {
            $a_qr[] = "$key = '$value'";
        }
        $ss_str = implode(',',$a_qr);
        $qr.= $ss_str;
        $qr.= " where id_$table = '$id'";
        mysql_query($qr);
        return true;
    }

}
?>

January 28, 2011

my class file

<?php
class User
{
    public function SelectRecords()
    {
        $sr_u = "select * from category";
        $o_user  = mysql_query($sr_u);
        $data = array();
   
        while($as__user = mysql_fetch_assoc($o_user))
        {
           
            $data[] = $as__user;
        }
            return $data;
       
    }
    public function InserRecod()
     {
        extract($_POST);   
        $ss__qr = "insert into category values('','$t1')";
        $o_user = mysql_query($ss__qr);
   
     }
   
     public function SelectRecordspro()
    {
   
        $sr_u = "select * from product";
        $o_user  = mysql_query($sr_u);
        $data = array();
   
        while($as__user = mysql_fetch_assoc($o_user))
        {
           
            $data[] = $as__user;
        }
            return $data;
       
     }
      public function InserRecodpro()
     {
        extract($_POST);   
         $ss_qr = "insert into product values('','$name','$qty','$price','')";
        $o_user = mysql_query($ss_qr);
     }
     public function deleteRecord()
     {
        extract($_POST);
       $db = "delete from category where id_category =" .$_GET['id_category'];
       mysql_query($db);
       header('Location:category_view.php');
     }
}
?>

The Future of Technology: Emerging Trends to Watch in 2025

Introduction As we navigate through 2025, the technological landscape continues to evolve at an unprecedented pace. Innovations that once se...