Tuesday, February 24, 2015

Unselect Flex Grid

flx = FlexGrid Name

Just set flx.row=0 and flx.col=0

Export Grid to Excel VB, Visual Basic

 

Private Sub FlexToExcel()





Dim xlObject    As Excel.Application





Dim xlWB        As Excel.Workbook





        





    Set xlObject = New Excel.Application 












    'This Adds a new woorkbook, you could open the workbook from file also





    Set xlWB = xlObject.Workbooks.Add 





                





    Clipboard.Clear 'Clear the Clipboard





    With MSFlexGrid1





        'Select Full Contents (You could also select partial content)





        .Col = 0               'From first column





        .Row = 0               'From first Row (header)





        .ColSel = .Cols - 1    'Select all columns





        .RowSel = .Rows - 1    'Select all rows





        Clipboard.SetText .Clip 'Send to Clipboard





    End With





            





    With xlObject.ActiveWorkbook.ActiveSheet





        .Range("A1").Select 'Select Cell A1 (will paste from here, to different cells)





        .Paste              'Paste clipboard contents





    End With





    





    ' This makes Excel visible





    xlObject.Visible = True





End Sub





Thursday, February 19, 2015

Permalink Menghilangkan Index.php pada CodeIgniter PHP

Sebelumnya
http://localhost/belajar/index.php/menu
 ingin menjadi
http://localhost/belajar/menu

Bagaimana Caranya, Silahkan ikuti petunjuk dibawah ini :

Buka File Config
yang terdapat di folder Application -> Config -> Config.php

Set beberapa variable berikut :

$config['enable_query_strings'] = TRUE;
$config['uri_protocol']    =  'PATH_INFO';

Setelah itu buat file extension .htaccess

isikan dengan data berikut :

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]




Selesai. Silahkan mencoba!!

Menampilkan Image dari Blob MySQL PHP

Masukan Ke dalam Database  :

$db = mysqli_connect("localhost","root","","DbName"); //keep your db name
$image = addslashes(file_get_contents($_FILES['images']['tmp_name']));
//you keep your column name setting for insertion. I keep image type Blob.
$query = "INSERT INTO products (id,image) VALUES('','$image')";  
$qry = mysqli_query($db, $query);

 
Akses Image dari BLOB :
$db = mysqli_connect("localhost","root","","DbName"); //keep your db name
$sql = "SELECT * FROM products WHERE id = $id";
$sth = $db->query($sql);
$result=mysqli_fetch_array($sth);
echo '(img src="data:image/jpeg;base64,'.base64_encode( $result['image'] ).'"/)';


*) Catatan : sbelum img dan paling terakhir tanda "(" diganti dgn "<" juga ")" diganti dengan ">"

Monday, February 16, 2015

New Line at Send Email PHP

Set Configure HTML type

Change $config['mailtype'] = 'html';

and use


 or

Use double-quotes " instead of single-quotes '. This way the newline \n will work.
"\n";

Sending Email With PHP Code Igniter

Follow These step :

1. Download PHPmailer from original site. Choose Zip Package.
2. Extract the downloaded “Zip” file.
3. Open the extracted file and copy “class.phpmailer.php” and “class.smtp.php”.
4. Paste these Two Files in Codeigniter Libraries.and rename it to be “phpmailer.php” and “smtp.php”




Create a controller file :


if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class CIPHP extends CI_Controller {

function __construct(){

parent::__construct();

$this->load->library('phpmailer');

}


function send_email() {

$subject  = 'Test Email';

$name = 'resta';

$email = 'resta_ok@yahoo.co.id';

$body = "body Message";

$this->phpmailer->AddAddress($email);

$this->phpmailer->IsMail();

$this->phpmailer->From     = 'info@resta-ok.co.id';

$this->phpmailer->FromName = 'user name';

$this->phpmailer->IsHTML(true);

$this->phpmailer->Subject  =  $subject;

$this->phpmailer->Body     =  $body;

$this->phpmailer->Send();

}

}

New Line from text Area


Use nl2br

 
$name = htmlspecialchars($_POST['name']);
$message = nl2br(htmlspecialchars($_POST['message'])); 
 
 //begin of HTML message
$message = <<<EOF


Name:</b><br>
{$name}


Message:</b><br>
{$message}
</body>
</html>
EOF;