Results 1 to 5 of 5

Thread: Noob Help

  1. #1
    Join Date
    Mar 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Noob Help

    Hi Guys,

    I'm very new to php but managing to pick it up by searching around google but there is one thing I'm having problems with and I hope someone can help me. I would imagine it would be some kinda of loop but not sure what kind.
    Say i had a row in a mysql database and I wanted to echo a value from the row which in increments every time the page loads. What kinda function/loops would I need to do this? everything I have found so far echos all the rows at the same time and doesn't change every time the page is loaded.

    The reason i want to do this is I have a website that i built and its being advertised on google. On this website is a form, when someone submits that form their details are passed to the users email which is in the database. What i want is every time someone fills in their details on the form those details would be passed to the next person in the database row, then once the last person in the database has been sent to, i want the loop to start over again.

    Would really appreciate any help as I have been trying to figure this one out for a while now.

    Thanks
    Last edited by GreggH; 03-20-2009 at 12:25 PM.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I don't completely get what your trying to do here. Can you re-explain it in differeny words please?
    Jeremy | jfein.net

  3. #3
    Join Date
    Mar 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    Sorry I will try to explain a bit better. I have got a bit further in my attempt since i wrote that but still not got it working yet.

    Lets say for example I have 50 websites which are all identical except the details that are processed in the form are sent to the owners of the 50 websites. The I have 1 advertising on google that when someone clicks on that advertising they get directed to a php processing page which in turn will redirect them to the 1st site out of 50, then when the next person clicks on the advertising they will get redirected to the 2nd site out of the 50 and that will go on until all 50 sites have been visited and then the cycle will repeat.

    What i have kinda of worked out so far is that if I have a counter which I have done in a txt file which updates +1 everytime someone visits, then i have an associative array which would associate each number to a different url then redirect based on that. The problem i have been having at the moment is I cant get the count to go back to the start again it just keeps going up. This is what i have for my count so far.

    PHP Code:
    <?php
    $File 
    "counter.txt";


    $handle fopen($File'r+') ;


    $data fread($handle512) ;

    if (
    $count 50){
        
    $count 1;
        
    fseek($handle0) ;
        
    fwrite($handle$count) ;}
    else
    $count $data 1;


    print 
    "You are visitor number ".$count;


    fseek($handle0) ;


    fwrite($handle$count) ;


    fclose($handle) ;


    ?>

    I haven't even started with the array yet. Maybe you would know an easier way to do this.
    Thanks

  4. #4
    Join Date
    Aug 2006
    Posts
    1
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by GreggH View Post
    Hi,

    Sorry I will try to explain a bit better. I have got a bit further in my attempt since i wrote that but still not got it working yet.

    Lets say for example I have 50 websites which are all identical except the details that are processed in the form are sent to the owners of the 50 websites. The I have 1 advertising on google that when someone clicks on that advertising they get directed to a php processing page which in turn will redirect them to the 1st site out of 50, then when the next person clicks on the advertising they will get redirected to the 2nd site out of the 50 and that will go on until all 50 sites have been visited and then the cycle will repeat.

    What i have kinda of worked out so far is that if I have a counter which I have done in a txt file which updates +1 everytime someone visits, then i have an associative array which would associate each number to a different url then redirect based on that. The problem i have been having at the moment is I cant get the count to go back to the start again it just keeps going up. This is what i have for my count so far.

    PHP Code:
    <?php
    $File 
    "counter.txt";


    $handle fopen($File'r+') ;


    $data fread($handle512) ;

    if (
    $count 50){
        
    $count 1;
        
    fseek($handle0) ;
        
    fwrite($handle$count) ;}
    else
    $count $data 1;


    print 
    "You are visitor number ".$count;


    fseek($handle0) ;


    fwrite($handle$count) ;


    fclose($handle) ;


    ?>

    I haven't even started with the array yet. Maybe you would know an easier way to do this.
    Thanks
    hey
    so you want to split your paid traffic between 5 or more sites?
    if yes, i write an example for u. try this
    PHP Code:
    <?php
    $sites_list 
    = array(
                        
    'http://www.google.com',
                        
    'http://www.aol.com',
                        
    'http://www.yahoo.com',
                        
    'http://www.msn.com',
                        
    'http://www.meebo.com');





    $counter_text_file "counter.txt";
    $present file_get_contents($counter_text_file);
    $lastone intval($present) + 1;

    $count count($sites_list);


        
    if(
    $present < ($count-1))
    {
        
    //file_put_contents("counter.txt", $lastone);
        
    $handle fopen($counter_text_file'w');
        
    fwrite($handle$lastone);
        
    fclose($handle);
    }
    else
    {
        
    //file_put_contents("counter.txt", 1);
        
    $handle fopen($counter_text_file'w');
        
    fwrite($handle0);
        
    fclose($handle);
    }




    print 
    "You are being redirect to ".$sites_list$present ];
    ?>

  5. The Following User Says Thank You to AlilG For This Useful Post:

    GreggH (03-19-2009)

  6. #5
    Join Date
    Mar 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    That i perfect, thanks so much you have no idea how long i have been trying to do this...lol really appreciate your help

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •