Pages

Friday, December 9, 2011

How to replace all spaces in url

Url now should be seo friendly as possible to make it indexed by google quickly. Therefore, many urls use the article title of which is of course could contain spaces. Then how to replace spaces with certain characters in the url ??.
The following script can be used :
$url = strtolower(str_replace(array('  ', ' '), '-', preg_replace('/[^a-zA-Z0-9 s]/', '', trim($string))));
Notes :
Those script using php
Replace '-' with any character as you wish
Those script convert all cases to lower

Thursday, December 8, 2011

How to make codeigniter without index.php

In codeigniter index.php will be included by default in the URL. We can remove it so that our URL should be like http://digilib.uad.ac.id/buku/Buku.
To do that just do the following steps:
  1. Open config.php in codeigniter application config directory
  2. replace $config['index_page'] = "index.php" with $config['index_page'] = ""
  3. Create a ".htaccess" file in the root of CodeIgniter directory
  4. write the following script:
    RewriteEngine on
    RewriteCond $1 !^(index\.php|resources|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
    

Wednesday, December 7, 2011

How to update some records in mssql

In certain conditions, we want to update some records, not all data. Suppose we want to update the first 100 data from a query. How to do it in MSSQL??.
The following query should be executed:
update top (100) table1 set field1 = 1
Notes
Make sure you replace "table1" with the actual table name.
And replace the field1, with your column names.
Don't Forget To Join Our Community
×
Widget