SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict stu567blue's Avatar
    Join Date
    Aug 2007
    Posts
    316
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    While Loop Not Outputting

    Hi All,

    Hope all is well... I'm having a problem with a while loop... from what I can see it all looks fine... I have a piece of javascript running within the PHP code that basically when its clicked is to show a textarea and it is to do this for each record in my table. I've put the code in below... any help would be great.

    Thank you

    PHP Code:
    while ($rowc mysql_fetch_array($resulta)) {
                                                                        
                                                                    
                                 echo 
    '<div id="profile_pic"/><a href="member-profile.php?member_id=' $rowc['member_id'] . '"/><img src="'.$rowc['profile_pic'].'" width="64" height="64" alt="" /></a></div>';
                                echo 
    '<div id="profile_holder">';
                                echo 
    '<div id="profile_info"><p><strong><a href="member-profile.php?member_id=' $rowc['member_id'] . '"/>' $rowc['firstname'] . ' ' $rowc['lastname'].'</a></strong> says '.$rowc['shared_deal'].'</p><br /></div>
                
                                <p><a href="#" onclick="document.getElementById(\'textHolder\').style.display=\'block\';" >Comment</a> | <a href="">Recommend</a></p>
                                <div id="textHolder" style="display:none;">
                                <form name="" method="POST" action="member-index.php?member_id='
    .$_SESSION['SESS_MEMBER_ID'].'">
                                <input type="hidden" name="member_id" valiue="'
    .$_SESSION['SESS_MEMBER_ID'].'"/>
                                <input type="hidden" name="firstname" value="'
    .$_SESSION['SESS_FIRST_NAME'].'"/>
                                <input type="hidden" name="lastname" value="'
    .$_SESSION['SESS_LAST_NAME'].'"/>
                                <input type="hidden" name="deal_id" value="'
    .$rowc['deal_id'].'"/>
                                <textarea rows="14" name="comment_text" cols="5" class="comment_area" placeholder="Enter Your Comment"></textarea>
                                                           <input type="submit" name="comment" value="Comment" />
                                </form>
    </div>'
    ;
                                echo 
    '</div>'

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,492
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    Just to be precise: the javascript doesn't run inside the php code, it's outputted like the rest of the html/css code and sent to the browser.

    As far as your problem is concerned, doesn't that loop output anything? Then your query isn't returning any rows.

  3. #3
    SitePoint Addict stu567blue's Avatar
    Join Date
    Aug 2007
    Posts
    316
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The loop outputs the records in the database... however when your click on the comment link where the Javascript is located it outputs one comment box at the top of the page... when what I want is each comment link to have its own comment box... if that makes sense

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,492
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    Maybe
    But that's a javascript question. I've moved this thread to the JS forum.
    Could you please post the resulting html/js code created by this script?

  5. #5
    SitePoint Addict stu567blue's Avatar
    Join Date
    Aug 2007
    Posts
    316
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just to be clear the While loop is written in PHP and the only Javascript that is within the code is in this line here:

    <p><a href="#" onclick="document.getElementById(\'textHolder\').style.display=\'block\';" >Comment</a> | <a href="">Recommend</a></p>
    When the user clicks the comment link it gets a div tag that contains a textarea as shown below:

    <div id="textHolder" style="display:none;">
    <form name="" method="POST" action="member-index.php">
    <input type="hidden" name="member_id" valiue=""/>
    <input type="hidden" name="firstname" value=""/>
    <input type="hidden" name="lastname" value=""/>
    <input type="hidden" name="deal_id" value=""/>
    <textarea rows="14" name="comment_text" cols="5" class="comment_area" placeholder="Enter Your Comment"></textarea>
    <input type="submit" name="comment" value="Comment" />
    </form>
    What needs to happen is when I click comment is for it to show a text area for each of the records in my database: Example if I see a status and I want to comment on this, I click comment and a textarea appears under that status.. once I've left comment I then see another status further down the page I press comment and what needs to happen is the textarea to appear below that persons status, not to go to the top of the page.

  6. #6
    SitePoint Addict stu567blue's Avatar
    Join Date
    Aug 2007
    Posts
    316
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey

    Quick update for you all.. I have solved the problem by using the deal_id in my table as a number to differentiate each of the different outputs...

    Thank you all for your advice


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
  •