October 23, 2009
Change path: app\code\core\Mage\Oscommerce\Block\Adminhtml\Import\Run.php, line no 160:
Change code
new Ajax.Request(“‘.$this->getUrl(‘*/*/batchRun’).’”, {
method: “post”,
to
new Ajax.Request(“‘.$this->getUrl(‘*/*/batchRun’).’”, {
method: “get”,
Leave a Comment » |
Magento |
Permalink
Posted by sabuj
July 25, 2009
We can change the element css classname using java script
document.getElementById("myid").className="myclass";
Here myid is the id name of your element and myclass is the new class name of that element.
Leave a Comment » |
CSS, Javascript |
Permalink
Posted by sabuj
May 5, 2009
Any one can easily find out the number of word in a string using the code below.
<?php
$your_string = “This is test a string.”;
$words = count(explode(“ ”, $your_string));
echo "$your_string contains $words words";
?>
Leave a Comment » |
PHP |
Permalink
Posted by sabuj
February 5, 2009
Finding the common elements in two arrays is very easy.Just use a function array_intersect().
array array_intersect ( array $array1 , array $array2 [, array $ ... ] )
example:
<?php
$array1 = array("a" => "green", "red", "blue");
$array2 = array("b" => "green", "yellow", "red");
$result = array_intersect($array1, $array2);
print_r($result);
?>
The above example will output:
Array
(
[a] => green
[0] => red
)
Leave a Comment » |
PHP |
Permalink
Posted by sabuj
January 9, 2009
Sometime we need to convert string into image.But it is not hard.You can easily do this by following code in php.
<?
//Text Convert to Image
$text=”Hello word”;
//Create an image width=120 and height=25
$img = imagecreatetruecolor(120,25);
// Set Background Color
$bgcol = imagecolorallocate($img,225,235,215);
// Set Text Color
$textcol = imagecolorallocate($img,54,32,212);
//Set Background
imagefill($img,0,0,$bgcol);
//Draw String
imagestring($img,3,8,4,$text,$textcol);
header(“Content-type: image/png”);
imagepng($img);
imagedestroy($img);
?>
Leave a Comment » |
PHP |
Permalink
Posted by sabuj
December 27, 2008
The CSV file format is a file type that stores tabular data usually processed in applications like Microsoft Excel (XLS).You can easily export Mysql data to CSV file format using PHP Script.
Code Given below:
<?
$host = 'localhost'; //your Hostname
$user = 'username'; //Database Username
$pass = 'userpassword'; //Database Pasword
$db = 'userdb'; //Database name
$table = 'user_table'; //Table name
$file = 'export'; //CSV File name
$link = mysql_connect($host, $user, $pass) or die(“Can not connect.” . mysql_error());
mysql_select_db($db) or die(“Can not connect.”);
$result = mysql_query(“SHOW COLUMNS FROM “.$table.”");
$i = 0;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$i++;
}
}
$values = mysql_query(“SELECT * FROM “.$table.”");
while ($rowr = mysql_fetch_row($values)) {
for ($j=0;$j<$i-1;$j++) {
$csv_output .=’”‘.$rowr[$j].”\”; “;
}
$csv_output .=’”‘.$rowr[$j].”\”";
$csv_output .= “\n”;
}
$filename = $file.”_”.date(“Y-m-d_H-i”,time());
header(“Content-type: application/vnd.ms-excel”);
header(“Content-disposition: csv” . date(“Y-m-d”) . “.csv”);
header( “Content-disposition: filename=”.$filename.”.csv”);
print $csv_output;
exit;
?>
Leave a Comment » |
MySql, PHP | Tagged: MySql, PHP |
Permalink
Posted by sabuj
November 25, 2008
You can easily find out longitude and latitude from Google map.Give an address and find out longitude and latitude.
<?
// Your Google Maps API key
$key = "YOUR_KEY_HERE";
$mapaddress = urlencode(“$address $city $state”);
// Desired address
$url = “http://maps.google.com/maps/geo?q=$mapaddress&output=xml&key=$key”;
// Retrieve the URL contents
$page = file_get_contents($url);
// Parse the returned XML file
$xml = new SimpleXMLElement($page);
// Parse the coordinate string
list($longitude, $latitude, $altitude) = explode(“,”, $xml->Response->Placemark->Point->coordinates);
// Output the coordinates
echo “latitude: $latitude, longitude: $longitude
“;
?>
Leave a Comment » |
Google Map |
Permalink
Posted by sabuj