<?php
$random = md5(uniqid());
echo $random;
?>
Monday, July 28, 2008
How to get a random alpha numeric value php - uniqid()
If you want to get a random alpha numeric value (Numbers and letters) in php you can use uniqid() (Only works in php 5 or later)
Wednesday, July 23, 2008
How to find duplicate rows in mysql using php
There are times when you need to find duplicate rows or records in a mysql table.
This mostly happens when you import data sources from out side(CSV,EXCEL,SQL)
Following code will show you how to find duplicates,
This code will group the given column and see if the grouped columns have more than one record
This mostly happens when you import data sources from out side(CSV,EXCEL,SQL)
Following code will show you how to find duplicates,
select count(*) as num, ID, Name from table
group by ID,Name
having count(*) > 1
This code will group the given column and see if the grouped columns have more than one record
+-----+------+------------+
| num |ID | Name |
+-----+------+------------+
| 3 | 1 | Kuppiya |
+-----+------+------------+
| 2 | 3 | Apple |
+-----+------+------------+
Friday, July 18, 2008
How to get distinct(unique) rows from mysql table using php
Friday, July 11, 2008
How to find mysql query returned row count using php
Thursday, July 10, 2008
How to get the size of an array in php - Find Array Size
Following code will show you how to get the size(Element count) of a array in php using count() and sizeof() (sizeof is same as count() )
<?php
$myA[0] = 12;
$myA[1] = 8;
$myA[2] = 20;
$arr_size = count($myA);
echo $arr_size; // 3
//you can also use sizeof()
//sizeof() is a alias for count()
$arr_size2 = sizeof($myA);
echo $arr_size2; // 3
?>
Tuesday, July 8, 2008
How to turn off error reporting in php Using php code - error_reporting()
If you want to turn off any errors and warning from displaying in the web page, The easiest way is to modify the php.ini file.
But what if you want to turn off error reporting in php using your php code? you can accomplish this easily using php built in function error_reporting()
More info : http://www.php.net/error_reporting
But what if you want to turn off error reporting in php using your php code? you can accomplish this easily using php built in function error_reporting()
<?php error_reporting(0); // Turn off all error reporting ?>
More info : http://www.php.net/error_reporting
Sunday, July 6, 2008
Redirect a page OnSubmit using radio buttons and php
Do you need a simple form which redirect to a new page when you select a relevant Radio button and submit? Take a look at the following code, pretty simple :)
<?php
//check if submit button is pressed
if(isset($_POST['sub']))
{
$path_id = $_POST['test'];//get selected radio button value
if($path_id == 1)
{
header("Location: page1.php");//redirect to the new page
}
else if($path_id == 2)
{
header("Location: page2.php");
}
else if($path_id == 3)
{
header("Location: page3.php");
}
}
?>
<html>
<head>
<title>test</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="test.php">
Form1:
<input type="radio" name="test" id="test" value="1" />
Form2:
<input type="radio" name="test" id="test" value="2" />
Form3:
<input type="radio" name="test" id="test" value="3" />
<br />
<br />
<input type="submit" name="sub" value="submit" />
</form>
</body>
</html>
Thursday, July 3, 2008
How to check if a php variable is empty or not using PHP
Tuesday, July 1, 2008
HTML MARQUEE UP - Simple News Bar Using Marquee
If you want to add a simple News bar (News reel) to your website, you can do it easily using a HTML MARQUEE tag, you only need to change the direction property to UP
Try this code out
Try this code out
<div width="35">
<marquee bgcolor="skyblue" scrollamount="2"
direction="up" width="35%">
<strong>
THIS IS A SIMPLE NEWS REEL<br>
You can add many lines<br>
THIS IS ANOTHER LINE<br>
<strong>
</marquee>
</div>
Subscribe to:
Posts (Atom)