Web Analytics Made Easy -
StatCounter couldn't get any values... - CodingForum

Announcement

Collapse
No announcement yet.

couldn't get any values...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • couldn't get any values...

    I am trying to make comparable date format, like - 20050802. But this code does not show any values. Any comment would be appreciated.

    Code:
    schema::
    CREATE TABLE `fts_consolation` (
    								 `subjk_id` int(11) NOT NULL auto_increment,
                                `subjk_num` int(11) NOT NULL default '0',
                                `subjk_reply` varchar(10) NOT NULL default '',
                                `subjk_parent` int(11) NOT NULL default '0',
                                `subjk_is_comment` tinyint(4) NOT NULL default '0',
                                `subjk_comment` int(11) NOT NULL default '0',
                                `subjk_datetime` datetime NOT NULL default '0000-00-00 00:00:00',
                                PRIMARY KEY  (`subjk_id`),
                                ) ENGINE=MyISAM DEFAULT CHARSET=utf8
     
     code::
                                
    @conn = mysql_connect(host, user, pass);
    $sql = " SELECT * FROM `g4_write_dmn_consolation`  order by wr_id  ";
        $res = mysql_query($sql) or die(mysql_error().'<hr />'.$sql);;
        for ($i=0; $row=mysql_fetch_array($res); $i++)
        {
        	echo $row[subjk_name];
    		echo $row[subjk_subject];
    		$mdatem=substr("$row[subjk_datetime]",-4,2);
    		$mdated=substr("$row[subjk_datetime]",-2,2);
    		echo $mdatem;
    		echo $mdated;
    	  }

  • #2
    MySQL has built in date formatting functions , you should utilise them when you can ... download the MySQL manual for all the good stuff
    PHP Code:
    <?php
    $sql 
    "
    SELECT DATE_FORMAT( subjk_datetime , '%Y%M%D' ) as subjk_datetime 
    FROM g4_write_dmn_consolation
    "
    ;

    $yaks mysql_query$sql ) ;
    while( 
    $r mysql_fetch_assoc$yaks ) ){
      echo 
    $r['subjk_datetime'] .'<br />' ;
    }
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

    Comment


    • #3
      Really appreciated.

      I can see values...

      Originally posted by firepages
      MySQL has built in date formatting functions , you should utilise them when you can ... download the MySQL manual for all the good stuff
      PHP Code:
      <?php
      $sql 
      "
      SELECT DATE_FORMAT( subjk_datetime , '%Y%M%D' ) as subjk_datetime 
      FROM g4_write_dmn_consolation
      "
      ;

      $yaks mysql_query$sql ) ;
      while( 
      $r mysql_fetch_assoc$yaks ) ){
        echo 
      $r['subjk_datetime'] .'<br />' ;
      }
      ?>

      Comment

      Working...
      X