Posts

Showing posts from April, 2012

list of table and database in php mysql

<?php $con  =  mysql_connect ( 'localhost'  ,  'root'  , '' ); mysql_select_db ( 'demo'  ,  $con  );  $sql  =  "SHOW TABLES FROM demo" ; $result  =  mysql_query ( $sql );  echo  ' Total Table = '  .  mysql_num_rows ( $result ); // list of table in database  while ( $row  =  mysql_fetch_row ( $result )) {     echo  "<br> {$row[0]}\n" ; } mysql_free_result ( $result ); ?> <?php // list of database  $dblist  =  mysql_query ( "SHOW DATABASES" ); echo  '<br> Total Database :' .  mysql_num_rows ( $dblist ) .  '<br> ' ; while ( $row  =  mysql_fetch_assoc ( $dblist )) {     echo  $row [ 'Database' ] .  "<br>" ; }

how to use codeigniter framework

Codeigniter    Codeigniter = > folder name  1. Database :-  Codeigniter => Application => config = >database.php 2.    change base url in codeigniter  Codeigniter => Application => config => config.php     $config['base_url']= 'http://localhost/CodeIgniter/'; 3.    create a welcome message in codeigniter  static page 3.1  Codeigniter => Application => controllers => hello.php (first page) <?php   class  Hello  extends  CI_Controller  {           public  function  you ()     {          $this -> load -> view ( 'my_view' );  ...

how to create image captcha in php

      demo.php  <?php session_start ();  if ( $_POST [ "vercode" ] !=  $_SESSION [ "vercode" ] or  $_SESSION [ "vercode" ]== '' )  {       echo   '<strong>Incorrect verification code.</strong>' ;  } else {        // add form data processing code here        echo   '<strong>Verification successful.</strong>' ;  };  $text1  =   md5 ( microtime ());  // rand(10000,99999);  $text  =  substr ( $text1 ,  0 ,  5 ); $_SESSION [ "vercode" ] =  $text ;  ?>  <form action="demo.php" method="post" style="width:400px; height:400px; ">  <img src=" demo1.php ?str= <?php  echo  $_SESSION [ "vercode...

MVC rule

1. mySQL tables will always be lowercase and plural e.g. posts, books 2. Models will always be singular and first letter capital e.g. Post, Book 3. Controllers will always have “Controller” appended to them. e.g. PostController, BookController 4. Views will have plural name followed by action name as the file. e.g. posts/view.php, books/buy.php 1.  Controller  => accept url request  2. modal  => database operation  3. view  =>  design

DataBase Query in WordPress

1. select query  <?php global  $wpdb  ; $myrow  =  $wpdb  ->  get_result (  'SELECT * FROM TableName'  ); foreach( $myrow  as  $row ){ echo  $value  =  $row  ->  Columan_Name } ?> 2. update query in wordpress  <?php  $wpdb  ->  query (  "UPDATE TableName SET col1 = 'val1' , col2 = 'val2' WHERE id=1 "  ) ; ?> 3. delete query in wordpress  <?php  $wpdb  ->  query (  "DELETE FROM TableName WHERE id = 2"  ) ; ?>

ODBC connection With MS Access DataBase in PHP

<html> <body> <?php //odbc conncetion with MS Access // create database in ms access  /* control pannel => Administrative Tools =>  Data Sources (ODBC) =>System DSN  => add => Microsoft Access Driver =>Finish Create => 'name of database and select location' // open database and create table  */ // Configuration Variables **/  define ( 'DB_NAME' ,  'db1.mdb' );   // db1.mdb  database name  define ( 'DB_USER' ,  '' );  define ( 'DB_PASSWORD' ,  '' );  $dbq = dirname ( $_SERVER [ 'SCRIPT_FILENAME' ]).  '/' . DB_NAME  ;  // database location        if  (! file_exists ( $dbq )) { ...

File uploading in PHP code

<?php // upload file into folder  #################### code for Create Thumb of Image ############### function  make_thumb ( $src , $dest , $desired_width , $desired_height = "188" ){    /* read the source image */    $ext  =  substr ( strrchr ( $src ,  '.' ),  1 );   if( $ext != 'gif' ){    $source_image  =  imagecreatefromjpeg ( $src );   } else {     $source_image  =  imagecreatefromgif ( $src );   }    $width  =  imagesx ( $source_image );    $height  =  imagesy ( $source_image );    //  $desired_height = "188";//floor($height*($desired_width/$width));    $virtual_image  =  imagecreatetruecolor ( $desired_width , $desired_height );    /* copy source i...

only number key in javascript

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script> function IsNumber(evt,x)  {          var charCode = (evt.which) ? evt.which : event.keyCode ; //alert(charCode); if(charCode != 46 && charCode != 45){ // . = 46 , - = 45          if ((charCode > 31 && (charCode < 48 || charCode > 57)) )             return false; //alert($('#txtts').val()); var s= $(x).val().split('.') ; if(s[1].length > 1){ return false ;};          return true; }else if(charCode==45){ if($(x).val().length!=0) return false ; }  if(charCode==46){  if($(x).val().indexOf('.')!='-1'){ return false ;};  } var s= $(x).val().split('.') ; if(s[1].length > 1){ return false ;}; return true;       } </script>  ...

remove space in javascript

<script> function loadd(){ ss = $('#t').val(); $('#loaddata').load('demo2.php?s='+ escape (ss)); } </script>

implode and explode function in php

implode and explode function in php how to use implode function in php how to use explode function in php <?php // explode function in php  ( string into array ) $str  =  "rajeev-dhar-dwivedi" ; $exarr  =  explode ( "-" , $str ); print_r ( $exarr );  // output : Array ( [0] => rajeev [1] => dhar [2] => dwivedi ) ?> <?php // Implode function in php  ( array into string ) $arr  = array( 'rajeev'  ,  'dhar'  , 'dwivedi' ); $impstr  =  implode ( "-" , $arr ); echo  $impstr  ;  // output :  rajeev-dhar-dwivedi ?>