Jump to content

spiderwell

Members
  • Posts

    1,008
  • Joined

  • Last visited

Posts posted by spiderwell

  1. ok this works but of course the switch statement will expand with more pages or offers:

    <?php
    function updatefile($newcounthandle){
    $counthandle=fopen("file.txt","w"); 
    fwrite($counthandle,$newcounthandle);
    fclose($counthandle);
    }
    $counthandle=fopen("file.txt","r"); 
    $getcurrent=fread($counthandle,filesize("file.txt"));
    fclose($counthandle);
    echo $getcurrent;
    switch ($getcurrent){
    case "1,1":
    	updatefile("1,2");
    	//redirect to lp1,offer1
    break;
    case "1,2":
    	updatefile("2,1");
    	//redirect to lp2,offer1
    break;
    case "2,1":
    	updatefile("2,2");
    	//redirect to lp1,offer2
    break;
    case "2,2":
    	updatefile("1,1");
    	//redirect to lp2,offer2
    break;
    default://incase nothing in file or out of specified ranges
    	updatefile("1,2");
    	//redirect to lp1,offer1
    break;
    }
    
    ?>
    

     

    note i have changed around a bit, in text file 1,1 : the first one is landing page, the second 1 is offer

    going to try an array version now lol but don't hold ya breath lol

  2. im working on this one a bit more first, but that said i might have 2 solutions in the end, using the arrays again on teh second, depends how much i procrastinate on this instead ofdoing my own stuff, lol

  3. ok so i have ended up using a switch statement dispite everything i said before. it sort of works, only I cant get the file open mode right.

     

    text file:

    1,1
    

    php file:

    <?php
    $counthandle=fopen("file.txt","r+"); //w+ indicates read and write and empty file contents upon writing, rather than appending which r+ would do(this is where I am getting stuck)
    $getcurrent=fread($counthandle,filesize("file.txt"));
    echo $getcurrent;
    switch ($getcurrent){
    case "1,1":
    	//redirect to lp1,offer1
    	fwrite($counthandle,"1,2");
    break;
    case "1,2":
    	//redirect to lp1,offer2
    	fwrite($counthandle,"2,1");
    break;
    case "2,1":
    	//redirect to lp2,offer1
    	fwrite($counthandle,"2,2");
    break;
    case "2,2":
    	//redirect to lp2,offer2
    	fwrite($counthandle,"1,1");
    break;
    default://incase nothing in file or out of specified ranges
    	//redirect to lp1,offer1
    	fwrite($counthandle,"1,2");
    break;
    }
    fclose($counthandle);
    
    ?>
    

    only the script is appending on the end, and not overwriting, if i open in w+ mode it hangs on the file size bit :(. This is because I am trying to only open the file object once, you could easily re work this to just open file, read, close. open file, write, close

     

     

  4. i think i am getting more confused

     

    does the user input something on page 2 in the text area that determines the extra rows in page 3?

     

     

    relaying what I said earlier, and as from your 1st post you can trigger a js function by echoing it into the page via php, and even pass variables to it like this

     

    $passinginfo = $_POST['textarea'];
    echo "<script type='text/javascript'>functionName(" . $passinginfo . ");</script>";
    

    but the jscript will only , as wildteen states, affect the compiled html page, and not affect the php

    but if you know in javascript how many extra rows to echo, why not just do that in php?

     

     

  5. if your host has mysql they might well have something in a cpanel. and failing anything in the cpanel, phpmyadmin is a very simple install.

    without a database you can still do it

     

    I think then a combination arrays and textfile for storing the current offer and page will do the job just as well though. you should be able to read and write to a file in one object and use that to get current page/offer array, as well as updating it for the next user to hit the site. then from there just pull the info from the other arrays storing the pages and offers. way I see it only one thing changes and thats the page/offer combo so thats the only thing that needs to be in a text file. obvioulsy afte ra month a set of new offers might be available but just change that manually as and when.

     

    databases are awesome btw, they are essentially textfiles too, but with a very good supporting set of functions and operations e.g. SQL language of some sort, which allows excellent colation and manipulation of data.

     

     

  6. you want to select all from video and inner join category on to that table where blah blah.

     

    then you have one record set with only the categorys listed in the video table and not a full list of categorys

     

    do you know enough sql to do that?

  7. You can use PHP to include or not include javascript functions in a compiled page, as I have done that and the OP code does just that, but as wildteen states, actually calling them from one language to another cannot be done

     

    if you are basing part 3 on $_POST data from part 2, to create the form, you shuoldn't need JS at all, as all the info you need to create the form 'should' be available in php and be executeable that way.

    posting code of the forms so far would help out a lot

  8. an html table?

     

    does the js execute after all the php stuff is done because your example should work then when page is pushed to client as i did something similar once attaching a ckedit js object to a textarea

     

  9. is the title in $header? or any of the php variables you have? substr() should sort that out easily enough.

    If you dont have 'control 'of the title, you might have use javscript to amend it client side directly in the iframe, but that sounds like a bitch to me  :P

     

    you might get more knowledgeable people on the facebook developers page who know this?

  10. you can use the gd() object for image manipulation to get the width and height, personally i would use a dynamic thumbnail script (that someone else wrote since theres plenty of them) to display the image to any size/proportion i chose. it would look something like <img src="thumbnailscript.php?file=picture.jpg&width=100&height=200"> passing the info to the php to spit out the image how you want it

     

    or use javascript to resize it client side, but of course that relies on javascript to be turned on (who even turns it off anyway I ask myself!!)

  11. google had plenty for me: http://www.google.co.uk/search?hl=en&q=friends+list+database+php&meta=

     

    as above really, have a table called friends, and note I haven't given this much thought, with a userid | friendid | status | columns.

    Only problem i would see is if obama added osama, obama would be the userid and osama would be friendid, whereas if it was osama adding first it would be reverse. This might cause other issues when checking if someone is already a friend on not, depending on who added who first.

     

     

    add me as a friend once you have done it  :P

  12. is the page rotation and offer rotation to work per user or for all users

     

    i.e dave arrives at your site and gets page1, offer 1

    then pete arrives and gets page2 offer 1....  or should he also get page1,offer1

    if its global, dave refreshes the page and gets page2 offer1, or since pete had that page, would dave then get page1 offer2?

     

    and how long does the rotation last? as a session variable (only while visitor is on site), a cookiee (can be months)

     

    or put it all another way, does each visitor get to see every offer in rotation, or just chance what rotation is when they arrive. I guess thats the difference between global and specific roation if that makes anysense.

     

    only the code solution would be quite different

     

    with your current code, you can certainly make it cleaner, as you could store all the info on 1 text file for starters.

    I think arrays might be a good solution if you cant use a database.

    $currentinfo = array("page"=>1,"offer"=>1);
    $pages = array(1=>"lp1.php",2=>"lp2.php",3=>"lp3.php");
    $offers = array(
    $offer1= array("offer"=>"UGG Shoes","link"=>"offer1.php"),$offer2 = array("offer"=>"iphone 4","link"=>"offer2.php"),$offer3 = ("offer"=>"karma sutra dvd","link"=>"offer3.php")
    );
    
    essentially you would update the $currentinfo array to hold current landing page and , and from that derive the page and offer needed. it is easily expandable in this format too. The current infoarray could be held in the session variable if its to be per user, otherwise you need to keep it somewhere where it gets updated by any users (i.e in a text file/database)
    
    

  13. the 3rd page of code from wildteen does it, just change it to pass the data to the $text variable for your email instead

    foreach($_SESSION['step1_data'] as $field => $value)   
    {        
    if($field != 'step1_submit')  echo "<p><b>$field</b> = $value</p>";  
      }
    

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.