SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,934
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Problem with Sticky Form Syntax

    Ugh! I have a PHP echo statement from hell?!

    I am trying to make the following Radio Buttons "sticky" but can't get the echo syntax figured out...
    PHP Code:
    // Display Friend-Requests.
    echo "<li>
            <a href='/account/profile.php?user=
    $username&tab=about-me'>
                
    $username<br />
                <img src='/uploads/" 
    $photoName "' width='80' alt='Thumbnail of ' . $username />
            </a>
            <fieldset id='friendRequestDecision'>
                <input id='" 
    $requestorID "_1' name='friendRequestDecision[" $requestorID "]' type='radio' value='0' checked='checked' />
                <label for='" 
    $requestorID "_1'>Decide Later</label>
                <input id='" 
    $requestorID "_2' name='friendRequestDecision[" $requestorID "]' type='radio' value='1' />
                <label for='" 
    $requestorID "_2'>Accept</label>
                <input id='" 
    $requestorID "_3' name='friendRequestDecision[" $requestorID "]' type='radio' value='2' />
                <label for='" 
    $requestorID "_3'>Decline</label>
            </fieldset>
        </li>\n"

    I am trying to get this new code to work...
    PHP Code:
    // Display Friend-Requests.
    echo "<li>
            <a href='/account/profile.php?user=
    $username&tab=about-me'>
                
    $username<br />
                <img src='/uploads/" 
    $photoName "' width='80' alt='Thumbnail of ' . $username />
            </a>
            <fieldset id='friendRequestDecision'>
                <input id='" 
    $requestorID "_1' name='friendRequestDecision[" $requestorID "]' type='radio' value='0' " 
                
    . (isset($friendRequestDecision[$requestorID]]) && $friendRequestDecision[$requestorID] == '0') ? "checked='checked'" "") . " />
                <label for='" 
    $requestorID "_1'>Decide Later</label>

                <input id='" 
    $requestorID "_2' name='friendRequestDecision[" $requestorID "]' type='radio' value='1' />
                <label for='" 
    $requestorID "_2'>Accept</label>

                <input id='" 
    $requestorID "_3' name='friendRequestDecision[" $requestorID "]' type='radio' value='2' />
                <label for='" 
    $requestorID "_3'>Decline</label>
            </fieldset>
        </li>\n"


    Could someone please help me figure this out?

    Thanks,


    Debbie

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,198
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    What is the output of $friendRequestDecision and $requestorID as it may be that the array index doesn't exist, please use the below code before your echo statement which will help us to help you.

    PHP Code:
    echo '<pre>';
    print_r($friendRequestDecision);
    echo 
    '</pre>';
    echo 
    $requestorID

  3. #3
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    I"m guessing this is inside a FOREACH on $requestorID, and you've extracted the values for $_POST['friendRequestDecision'] into $friendRequestDecision.

    Assuming those two things, the code looks mostly good.... you've got some syntax issues up in your image.
    Might want to not line break right before the piece you're about to enter, but that shouldnt cause an issue.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


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
  •