<script type="text/javascript"> //visit kuppiya.com var myKey = /kuppiya/; var myStringVar = "I Love kuppiya"; var myMatch = myStringVar.search(myKey); if(myMatch != -1) { alert("Wow There is a match "); } else { alert("hmmm no match"); } </script>
Saturday, June 28, 2008
Search a String JavaScript - (Like strstr in php)
you want to search a keyword(String) within a given String using Javascript? need a function like strstr() in php? Then you should look at this code, like in php I haven't seen a built in function to do this but by using some regular expression you can accomplish this task
Wednesday, June 25, 2008
How to make first letter uppercase (Capital) using PHP
You want to make your first letter in your string uppercase(Capital) using php?
have no fear you can use php built in function ucfirst()
http://www.php.net/manual/en/function.ucfirst.php
If you like to learn about SLIIT please visit www.sliit.lk
have no fear you can use php built in function ucfirst()
<?php
$my_string = 'my kuppiya';
$my_string = ucfirst($my_string);
echo $my_string; //My kuppiya
?>
http://www.php.net/manual/en/function.ucfirst.php
If you like to learn about SLIIT please visit www.sliit.lk
Wednesday, June 18, 2008
How to refresh parent window when closing popup window
You open a popup and when a update done in popup window you need to refresh or reload the parent window. How can you reload or refresh your parent? here's how its done.
window.close(); // close the popup
if (window.opener && !window.opener.closed)
{
//if parent available
window.opener.location.reload(); //reload parent
}
Monday, June 16, 2008
How to get the MySql last inserted row using PHP?
When you use a auto increment primary key id field, you usually have no track of what is the current inserted id in the auto increment field. But there are situation where you need to know the last increamented id.
You can simply use mysql_insert_id()
You can simply use mysql_insert_id()
<?php
mysql_query("insert into mytable (v_name) values ('kusal')");
$last_id = mysql_insert_id();
echo $last_id;
?>
Wednesday, June 11, 2008
How to get String Length in JavaScript
Wednesday, June 4, 2008
How to select a random row from mysql table
Are you looking a way to get a random record from a mysql table?, want to do it by single and a simple query? if the answer is yes, here it is
You can use mysql rand() function to easily get a random data row.
but be warned that for large data tables this function is said to be slow.
If you like to learn more about SLIIT please visit www.sliit.lk
SELECT * FROM table_name ORDER BY RAND() LIMIT 0,1
You can use mysql rand() function to easily get a random data row.
but be warned that for large data tables this function is said to be slow.
If you like to learn more about SLIIT please visit www.sliit.lk
Tuesday, June 3, 2008
How to get a random number in PHP
Looking a way to generate a random number using a PHP function.
Here how it's done, pretty easy to get a random number
to see more options in rand() function visit www.php.net/rand
Here how it's done, pretty easy to get a random number
<?php
echo rand();
?>
to see more options in rand() function visit www.php.net/rand
Subscribe to:
Posts (Atom)