1

(1 replies, posted in Code)

Hope it helps !!!

<?php
$sContents    =    "Jim,Smith,1234 Main Street,Anytown,NY,12345,206,123-3456\n";
$sContents    .=    "Aneesh,R,1234 Main Street,Anytown,NY,12345,206,123-3456\n";
$sContents    .=    "Sambhu,S,1234 Main Street,Anytown,NY,12345,206,123-3456";

foreach( explode("\n", $sContents) as $k=>$sContent ){
    $arrValues    =    explode( ",", $sContent );
    $arrGlobal[$arrValues[1]][]    =    $arrValues[1] ."," . $arrValues[0] ."," . $arrValues[7] ;
}
sort( $arrGlobal );
foreach( $arrGlobal as $Global ){
    echo $Global[0] ."<br>";
}
?>

2

(2 replies, posted in Code)

A small sample

<?php
$pattern = "^([A-Za-z0-9\.|-|_]{1,60})([@])";
$pattern .="([A-Za-z0-9\.|-|_]{1,60})(\.)([A-Za-z]{2,3})$";

ereg($pattern,$email)
?>

3

(9 replies, posted in Code)

http://www.w3schools.com/php/default.asp

4

(1 replies, posted in Code)

You can place a select box with all the available states in contacts and populate it in a select box.  Then after that based on the selected values pass query to the database

<select name="state">
<?php
$sql   =  "SELECT DISTINCT ( state ) FROM contacts ORDER BY state";
$res = mysql_query( $sql ) or die( mysql_error());
while( $row = mysql_fetch_object( $res ) ){
           echo '<option = '". $row->state ."'>'. $row->state .'</option>';
}
?>
</select>
<input type="submit" name="submit" value="search">

Then in the landing page do the following code

<?php 
if( isset( $_POST['state'] ) ){
       $sql = "SELECT * FROM contacts WHERE state = "".  $_POST['state'] ."'";
       //Remaining Operations
}

5

(2 replies, posted in Code)

You can use the NOW() function of mysql, and set the field data type as DATETIME

6

(2 replies, posted in Code)

Hi .. Yes You have to create these two files

include 'library/config.php';
Inside the above file you can put code some thing like this

<?php
$host = "localhost";//Your mysql host name
$user = "root";  //Username to access the database;
$pass = "password";//Password to access the database;
$db = "_db_name";//The database where you created the tables
?>

include 'library/opendb.php';

then in opendb.php add the following code

<?php
mysql_connect(  $host, $user, $pass  ) or die( mysql_error() );
mysql_select_db(  $db );
?>

Try this .. have a nice time ..