Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Friday, November 18, 2011

PHP Plugin for Eclipse

Hi Here is the Procedure to install the PHP Plugin in Eclipse. Click Here

Wednesday, July 13, 2011

Chrome Extension For PHP Manual

Hi All

Here is the Chrome Extension for PHP Manual (quick Reference).

https://chrome.google.com/webstore/detail/clbhjjdhmgeibgdccjfoliooccomjcab

Note:- This will work only in Google Chrome Browsers.

Thursday, December 16, 2010

Custom number of cloumns in each row

<?php
$array = array('a','b','c','d','e','f','g','h','i','j');
?>
<html>
<head>
<body>
<table>
<tr>
<?php
for($i=0;$i<count($array);$i++) {
    $j = $i+1;
?>
<td><?php echo $array[$i]; ?></td>
<?php if($j%4 == 0) { ?>
</tr>
<tr>
<? }
}
?>

Tuesday, September 28, 2010

Export Data From MySql DatabaseTable to Excel

$DB_Server = "localhost"; //your MySQL Server
$DB_Username = "root"; //your MySQL User Name
$DB_Password = ""; //your MySQL Password
$DB_DBName = "test"; //your MySQL Database Name
$DB_TBLName = "users"; //your MySQL Table Name
$ttype = $DB_TBLName;

$sql = "Select * from $DB_TBLName";

$Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password)
or die("Couldn't connect to MySQL:
" . mysql_error() . "
" . mysql_errno());
//select database
$Db = @mysql_select_db($DB_DBName, $Connect)
or die("Couldn't select database:
" . mysql_error(). "
" . mysql_errno());
//execute query
$result = @mysql_query($sql,$Connect)
or die("Couldn't execute query:
" . mysql_error(). "
" . mysql_errno());


while($row = mysql_fetch_row($result,MYSQL_ASSOC))
{
$data[] = $row;

}
//print_r($data);exit;

function cleanData(&$str) {
$str = preg_replace("/\t/", "\\t", $str);
$str = preg_replace("/\r?\n/", "\\n", $str);
if(strstr($str, '"'))
$str = '"' . str_replace('"', '""', $str) . '"';
}

// filename for download
$filename = "website_data_" . date('Ymd') . ".xls";
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
$flag = false;
foreach($data as $row) {
if(!$flag) {
//display field/column names as first row
echo implode("\t", array_keys($row)) . "\n";
$flag = true;
}
array_walk($row, 'cleanData');
echo implode("\t", array_values($row)) . "\n";
}
exit;

Thursday, June 3, 2010

Configuring PHP with IIS in Windows

1)Download and Install the Fast CGI Extension for IIS from http://www.iis.net/download/FastCGI.
2)Download the PHP windows binaries installer from  http://windows.php.net/download/.and install it.
3)type inetmgr in run command IIS Window will be open.
4)Right Click on Web Sites and click on properties.

Dialog box will be opened in that Click Home Directory tab in this Browse fro Local Path.
Here you have the Give the DocumentRoot.i.e Where you want to place your PHP Files.click Ok.


Now Create a php file(ex:phpinfo.php)

with the following code
<?
phpinfo();
?>
 and Place in that directory.


Now Browse for http://localhost/phpinfo.php

Monday, April 5, 2010

PHP code in HTML file

Hi All

Here is the way to write the PHP logic in HTML File(i.e .html file).

In two ways we can achieve this.

1.change the setting in apache configuration file(i.e httpd.conf)

AddType application/x-httpd-php .php ---> AddType application/x-httpd-php .php .html

2. If you don't have the access to httpd.conf you can write .htacees file as

AddType application/x-httpd-php .php .htm .html

and then restart the apache webserver.

Friday, August 7, 2009