php help

Discussion in 'PHP' started by kumar84, Aug 27, 2007.

  1. #1
    hi friends

    i need php coding for this scenario,

    <img src="pet1.jpg"> <a href="" > add to profile</a>
    <img src="pet2.jpg"> <a href="" > add to profile</a>
    <img src="pet3.jpg"> <a href="" > add to profile</a>
    <img src="pet4.jpg"> <a href="" > add to profile</a>
    <img src="pet.5jpg"> <a href="" > add to profile</a>

    if i click the first link it should pass the src as a string in one of the varibale $var and this variable($var) i should pass in one of the method named as $facebook->api_client->profile_setFBML($var,$user);

    if i click the second link it should pass the src as a string in one of the varibale $var and this variable($var) i should pass in same method (as mentioned above) named as $facebook->api_client->profile_setFBML($var,$user);

    like this it should go continuosly for every add to profile link

    but at the same time if i click the link add to profile once means it should not be given chance to click once again the link, the link should be disabled

    now for the second add to profile the same condition ,if i click the link add to profile once means it should not be given chance to click once again the link, the link should be disabled

    like that it should continously goes on



    can any body help me for this scenario in php coding
    Thanks in advance
     
    kumar84, Aug 27, 2007 IP
  2. webrickco

    webrickco Active Member

    Messages:
    268
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #2
    I believe you should consider two distinct implementations:

    - By adding the link into the profile, considerer to add javascript coding to resubmit the page with a specific action value that would trigger the method.

    <img src="pet1.jpg"> <a href="Javascript: addtoprofile('pet1.jpg');"> add to profile</a>

    addtoprofile should be a Javascript function that would only change the action value of the script to "addtoprofile" (for example) of the form, store the value of src into an hidden value and resubmit it.

    then your php script should consider executing the method considering the action value

    if ($_POST['action'] == "addtoprofile")
    profile_setFBML($_POST['hidden_value_for_src'],$user);

    - considering the disability when adding twice, your link should be place in php after you have verified that the profile belongs to that specific user. I suspect you have a method for that:

    in php:
    // verify link 'pet1.jpg' is already in profile

    if (true)
    echo "<img src=\"pet1.jpg\" title=\"Profile added to the user already\">
    else
    echo "<img src=\"pet1.jpg\"> <a href=\"Javascript: addtoprofile('pet1.jpg');\">";

    and so on for every option (consider to have a loop over a dynamic or static storing structure, array or query result)

    hope this helps
     
    webrickco, Aug 28, 2007 IP