grab data in database from ther side
<p>here is my code which i used to save data from other side ...
<a href="http://www.friends2support.org/inner/news/searchresult.aspx?BloodGroup=B%20&amp;state=27%7CdpState&amp;district=607%7CdpDistrict&amp;city=3352" rel="nofollow">LINK</a> of site from which i want to copy the data </p>

<pre><code>&lt;?php
    define('SQL_HOST','localhost');
    define('SQL_USER','root');
    define('SQL_PASS','');
    define('SQL_DB','donateblood');
    $conn = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS)
        or die('Could not connect to the database; ' . mysql_error());

    mysql_select_db(SQL_DB, $conn)
        or die('Could not select database; ' . mysql_error());

    $config['url']= "http://www.friends2support.org/inner/news/searchresult.aspx";
    // url of html to grab
    $config['start_tag'] = 'id="dgBloodDonorResults"'; // where you want to start grabbing
    $config['end_tag']   = ' End Code Here '; // where you want to stop grabbing
    $config['show_tags'] = 0; // do you want the tags to be shown when you show the html? 1 = yes, 0 = no

    //echo file_get_contents('http://www.friendstosupport.org/inner/news/searchresult.aspx?BloodGroup=A-&amp;state=22|dpState&amp;district=537|dpDistrict&amp;city=0|dpCity' );

    class grabber
    {
        var $error = '';
        var $html  = '';

        function grabhtml( $url, $start, $end )
        {
        $file = file_get_contents( $url );      
        if( $file )
        {
            echo $file;
            if( preg_match_all( "#$start(.*?)$end#s", $file, $match ) )
            {               
            $this-&gt;html = $match;
            }
            else
            {
            $this-&gt;error = "Tags cannot be found.";
            }
        }
        else
        {
            $this-&gt;error = "Site cannot be found!";
        }
        }

        function strip( $html, $show, $start, $end )
        {
        if( !$show )
        {
            $html = str_replace( $start, "", $html );
            $html = str_replace( $end, "", $html );
            return '&lt;table'.$html;
        }
        else
        {
            return '&lt;table '.$html;
        }
        }
    }


    $grab = new grabber;

    $settime=0;
    $user=array();
    $getset='false';

    while($settime&lt;=5)
    {
        $cur=array();
        while($getset=='false')
        {
            $grab-&gt;grabhtml( $config['url'], $config['start_tag'], $config['end_tag'] );
            echo $grab-&gt;error;
            $finaltxt='';
            foreach( $grab-&gt;html[0] as $html )
            {
                $finaltxt=$grab-&gt;strip( $html, $config['show_tags'], $config['start_tag'], $config['end_tag'] ) ;
            }

            $txt=explode('name="achrMore"',$finaltxt);
            $j=0;

            foreach($txt as $i)
            {
                $rest=strstr($i,"javascript:fnOpen('donorInformation.aspx?",true);
                $rest=substr($rest,0,strrpos($rest,'id'));
                echo $rest.'&lt;br&gt;';
                $cur[$j]=trim($rest, "javascript:fnOpen('");

                $cur[$j]=substr($cur[$j],0,-4);
                echo $user[$j].'-----------------'.substr($user[$j],0,-4).'&lt;br&gt;';
                $j++;
            }
            if($settime==0){$user=$cur;}
            $compare=array();
            $compare=array_diff($cur,$user);
            echo $settime.'&lt;br&gt;';
            print_r($cur);
            if(count($compare)==0)
            {
                $getset='true';
                $settime++; 
            }
            $user=array_merge($user,$compare);
            var_dump($user);
        }
    }

    echo '&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;';
    //print_r($user);
    $data=array();
    $in=0;
    foreach($user as $k)
    {
        $sconfig['url']= "http://www.friendstosupport.org/inner/news/".$k;
        //url of html to grab
        $sconfig['start_tag'] = '&lt;TABLE id="Table1"'; // where you want to start grabbing
        $sconfig['end_tag']   = '&lt;INPUT id="btnSubmit"'; // where you want to stop grabbing
        $sconfig['show_tags'] = 1; // do you want the tags to be shown when you show the html? 1 = yes, 0 = no

        $grab-&gt;grabhtml( $sconfig['url'], $sconfig['start_tag'], $sconfig['end_tag'] );
        echo $grab-&gt;error;
        $profile='';
        foreach( $grab-&gt;html[0] as $html )
        {
            $profile=$grab-&gt;strip( $html, $sconfig['show_tags'], $sconfig['start_tag'], $sconfig['end_tag'] );
        }
        $stxt=explode('&lt;TR&gt;',$profile);
        $j=0;
        $i=$profile;
        echo htmlspecialchars($i).'&lt;br&gt;&lt;br&gt;';

        foreach($stxt as $i)
        {
            $name='';$blood='';$gender=''; $mobile='';$landline='';$state=''; $city=''; $email=''; $address='';
            $data=strstr($i,'&lt;span id="lblFullName"&gt;',false);       
            echo $name=substr(strstr($data,'&lt;/span&gt;',true),'23',strlen(strstr($data,'&lt;/span&gt;',true)));  

            $data=strstr($i,'&lt;span id="lblBloodGroup"&gt;',false);     
            $blood=substr(strstr($data,'&lt;/span&gt;',true),'25',strlen(strstr($data,'&lt;/span&gt;',true)));

            $data=strstr($i,'&lt;span id="lblGender"&gt;',false);     
            $gender=substr(strstr($data,'&lt;/span&gt;',true),strlen('&lt;span id="lblGender"&gt;'),strlen(strstr($data,'&lt;/span&gt;',true)));  

            $data=strstr($i,'&lt;span id="lblDOB"&gt;',false);        
            $dob=substr(strstr($data,'&lt;/span&gt;',true),strlen('&lt;span id="lblDOB"&gt;'),strlen(strstr($data,'&lt;/span&gt;',true)));    

            $data=strstr($i,'&lt;span id="lblMobileNumber"&gt;',false);       
            $mobile=substr(strstr($data,'&lt;/span&gt;',true),strlen('&lt;span id="lblMobileNumber"&gt;'),strlen(strstr($data,'&lt;/span&gt;',true)));    

            $data=strstr($i,'&lt;span id="lblLandlineNumber"&gt;',false);     
            $landline=substr(strstr($data,'&lt;/span&gt;',true),strlen('&lt;span id="lblLandlineNumber"&gt;'),strlen(strstr($data,'&lt;/span&gt;',true)));    



            $data=strstr($i,'&lt;span id="lblState"&gt;',false);      
            $state=substr(strstr($data,'&lt;/span&gt;',true),strlen('&lt;span id="lblState"&gt;'),strlen(strstr($data,'&lt;/span&gt;',true)));

            $data=strstr($i,'&lt;span id="lblDistrict"&gt;',false);       
            $city=substr(strstr($data,'&lt;/span&gt;',true),strlen('&lt;span id="lblDistrict"&gt;'),strlen(strstr($data,'&lt;/span&gt;',true)));

            $data=strstr($i,'&lt;span id="lblEmailID"&gt;',false);        
            $email=substr(strstr($data,'&lt;/span&gt;',true),strlen('&lt;span id="lblEmailID"&gt;'),strlen(strstr($data,'&lt;/span&gt;',true)));

            $data=strstr($i,'class="textarea" OnKeyPress="javascript:return false;"&gt;',false);       

            $address='&lt;![CDATA['.substr(strstr($data,'&lt;/textarea&gt;',true),strlen('class="textarea" OnKeyPress="javascript:return false;"&gt;'),strlen(strstr($data,'&lt;/textarea&gt;',true))).']]&gt;';

            echo htmlspecialchars($name).'&lt;br&gt;';
            echo htmlspecialchars($blood);
            echo htmlspecialchars($gender);echo htmlspecialchars($mobile);echo htmlspecialchars($landline);echo htmlspecialchars($address);echo htmlspecialchars($email).'&lt;br&gt;';
            $j++;
        }

        //echo "i m here in sql command";

        $sql = "
            INSERT INTO donateblood 
                (user_id,name,bloodgroup,gender,mobile,landline,state,city,email,address) 
                VALUES ('".$k."','".$name."','".$blood."','".$gender."','".$mobile."','".$landline."','".$state."','".$city."','".$email."','".$address."')"; 
        $result = mysql_query($sql, $conn)or die('Could not retrieve page info; ' . mysql_error());
    }

?&gt;
</code></pre>
