# Inserting data in sql db

**URL:** <https://forum.kirupa.com/t/inserting-data-in-sql-db/259481>\
**Category:** Uncategorized\
**Created:** [May 5, 2008, 11:28pm UTC](https://forum.kirupa.com/t/inserting-data-in-sql-db/259481 "2008-05-05T23:28:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharkb8](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@sharkb8](https://forum.kirupa.com/u/sharkb8)\
**Post date:** [May 5, 2008, 11:28pm UTC](https://forum.kirupa.com/t/inserting-data-in-sql-db/259481/1 "2008-05-05T23:28:36Z")

</div>

I have a snippet of code which opens up a webpage with fopen and im grabbing the content from the page. I have 2 questions to this mystery:  
1)How do I filter out the content I need. Do I use a switch operation to achieve that?  
2)After I get the content, how do insert it into a db?

This is my code so far:  
$file = fopen(“[http://www.mysite.com/index.php/misc/aff/10","r](http://www.mysite.com/index.php/misc/aff/10%22,%22r)”);

while(! feof($file))  
{  
$titles[]=fgets($file);  
$titles= str\_replace(":affid2:",$\_SERVER[‘QUERY\_STRING’], $titles);

```
  while(list($index,$name) = each($titles))
    {
    
        echo $name;
    
    }

```

}

fclose($file);

Your help is greatly appreciated!
