reload windows for once

18 Nov 2008 In: Javascript
var reloaded = false;
var loc=""+document.location;
loc = loc.indexOf("?reloaded=")!=-1?loc.substring(loc.indexOf("?reloaded=")+10,loc.length):"";
loc = loc.indexOf("&")!=-1?loc.substring(0,loc.indexOf("&")):loc;
reloaded = loc!=""?(loc=="true"):reloaded;

function reloadOnceOnly() {
if (!reloaded)
window.location.replace(window.location+"?reloaded=true&cPath=2_25");
}
reloadOnceOnly();

preg_match + $_server

18 Nov 2008 In: Apache Useful Links, PHP

<?php

$geturl=$_SERVER['HTTP_HOST'];
if(preg_match("/xxx.com/i", $geturl))
{
$geturl=preg_replace('#aaa.com#is','',$geturl);
?>
<meta http-equiv='refresh' content='0; url=<?php echo $geturl;?>'>
< ?php

exit;

}

?>

Getting The Day of a Date YYYY-MM-dd

13 Nov 2008 In: PHP

$date = '2008-11-13';
echo date('l', strtotime($date));

*this will echo Thursday

/////////////////////////

$date = '2008-11-13';
echo date('D', strtotime($date));

*this will echo Thu

pull down menu

6 Nov 2008 In: OSCommerce

The script below getting the category from database and put it to a pull down menu:

$categories = array();
$categories_query = tep_db_query("select ". TABLE_CATEGORIES .".parent_id,". TABLE_CATEGORIES .".categories_id,". TABLE_CATEGORIES_DESCRIPTION .".categories_id,". TABLE_CATEGORIES_DESCRIPTION .".categories_name,". TABLE_CATEGORIES_DESCRIPTION .".language_id FROM " . TABLE_CATEGORIES_DESCRIPTION . ",". TABLE_CATEGORIES ." WHERE ". TABLE_CATEGORIES .".parent_id!=0  AND ". TABLE_CATEGORIES_DESCRIPTION .".language_id=1 AND  (". TABLE_CATEGORIES .".categories_id=". TABLE_CATEGORIES_DESCRIPTION .".categories_id) order by ". TABLE_CATEGORIES_DESCRIPTION .".categories_name");
while ($categories_values = tep_db_fetch_array($categories_query)) {
$categories_array[] = array('id' => $categories_values['categories_name'], 'text' => $categories_values['categories_name']);
}
echo tep_draw_pull_down_menu('categories', $categories_array);

array looping

25 Sep 2008 In: PHP
<?php

$thearray = array("green", "red", "yellow");
foreach($thearray as $key => $value) {
echo $key . " " . $value . "<br>";
}

?>

About

Web Siteblob is a collection of useful web development dictionary for web developers (beginner). Visitors can find information related to php, mysql, javascript, and some server configuration here.

We wish you can join as our member and start sharing your tricks with everyone.

As some of the information here is from other sites, credits will be given to these site by stating the source and adding the sites in our friend's link.

Thank you!


Sponsors