We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,497 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

I need help in php view page display records

HAi everybody,

I need help in flowing code

i want to people not equal to friend means show addas friend buuton otherwise not show button

this code show button more times

what is the problem in my logic

anybody plz help me.

This is my friends get query.

$query=$db->prepare("SELECT p.friend_id , p.layer_id
                                        from layer l, people p
                                        where l.personal_id = :personal_id
                                        and l.id = p.layer_id
                                        GROUP BY p.friend_id    


        "); 
        $query->execute(array('personal_id' => $this->personal->getId()));

            $this->friends = $query->fetchAll();






<?php 
                    foreach($people as $p): ?>

                    <div id="vv-ppl-profile" class="friends">
                        <h3><?php echo $p["full_name"] ?></h3>
                        <a href="viewprofile?personal_id=<?php echo $p['id'] ?>" > <div class="vv-ppl-profile-thumb" style="background-image:url('<?php echo url_for('@image_display_new?from='.$p['primary_album_id'].'&type=personal&pic_id='.$p['profile_picture_id'], true); ?>') " >
                     </div></a>

                        <?php foreach($friends as $fr):?>
                            <?php if(($fr['id'])!=($p['id'])):?>
                            <div class="vv-ppl-cta vv-ppl-add">
                                <input type="hidden" value="<?php echo $p['id'] ?>"  />
                                    <p>Add Friend</p>
                                </div>
                            <?php endif;?>

                        <?php endforeach;?>
                        <?php endforeach;?>
3
Contributors
5
Replies
52 Minutes
Discussion Span
3 Months Ago
Last Updated
7
Views
Vijaysurya
Light Poster
35 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

i want to people not equal to friend means show addas friend buuton otherwise not show button

What is the issue? You need to be more specific. Is there any errors when you run the code?

You have 2 <?php foreach;?> loops so was there an error?

If there's no error what data appears.

LastMitch
Industrious Poster
4,212 posts since Mar 2012
Reputation Points: 134
Solved Threads: 336
Skill Endorsements: 45

If no error means i want to show addas friend btn
i corrected my template but still show btn more than twice.

<?php endforeach;?>
</div>
<?php endforeach;?>
Vijaysurya
Light Poster
35 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

If no error means i want to show addas friend btn
i corrected my template but still show btn more than twice

Instead of this:

<?php foreach($people as $p): ?>
<div id="vv-ppl-profile" class="friends">
<h3><?php echo $p["full_name"] ?></h3>
<a href="viewprofile?personal_id=<?php echo $p['id'] ?>" ><div class="vv-ppl-profile-thumb" style="background-image:url('<?php echo url_for('@image_display_new?from='.$p['primary_album_id'].'&type=personal&pic_id='.$p['profile_picture_id'], true); ?>') " >
</div></a>
<?php foreach($friends as $fr):?>
<?php if(($fr['id'])!=($p['id'])):?>
<div class="vv-ppl-cta vv-ppl-add">
<input type="hidden" value="<?php echo $p['id'] ?>" />
<p>Add Friend</p>
</div>
<?php endif;?>
<?php endforeach;?>
<?php endforeach;?>

Try this (I took out the second loop):

<?php foreach($people as $p): ?>
<div id="vv-ppl-profile" class="friends">
<h3><?php echo $p["full_name"] ?></h3>
<a href="viewprofile?personal_id=<?php echo $p['id'] ?>" > <div class="vv-ppl-profile-thumb" style="background-image:url('<?php echo url_for('@image_display_new?from='.$p['primary_album_id'].'&type=personal&pic_id='.$p['profile_picture_id'], true); ?>') " >
</div></a>
<?php endforeach;?>

<?php foreach($friends as $fr):?>
<?php if(($fr['id'])!=($p['id'])):?>
<div class="vv-ppl-cta vv-ppl-add">
<input type="hidden" value="<?php echo $p['id'] ?>" />
<p>Add Friend</p>
</div>
<?php endif;?>
<?php endforeach;?>

What error did you get or what data appear?

LastMitch
Industrious Poster
4,212 posts since Mar 2012
Reputation Points: 134
Solved Threads: 336
Skill Endorsements: 45

i did not getin error,button show more times.

i want to everypeoplename and button
this button show in this condition based
<?php if(($fr['id'])!=($p['id'])):?>

for exp
Name
adas friend

name2
addasfriend

plz help me.

Vijaysurya
Light Poster
35 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

i want to everypeoplename and button
this button show in this condition based

Try this (Did you write this code with this kind of format):

<?php foreach($people as $p): ?>
<div id="vv-ppl-profile" class="friends">
<h3><?php echo $p["full_name"] ?></h3>
<a href="viewprofile?personal_id=<?php echo $p['id'] ?>" ><div class="vv-ppl-profile-thumb" style="background-image:url('<?php echo url_for('@image_display_new?from='.$p['primary_album_id'].'&type=personal&pic_id='.$p['profile_picture_id'], true); ?>') " >
</div></a>
<?php foreach($friends as $fr):?>
<?php endforeach;?>
<?php endforeach;?>

<?php if(($fr['id'])!=($p['id'])):?>
<div class="vv-ppl-cta vv-ppl-add">
<input type="hidden" value="<?php echo $p['id'] ?>" />
<p>Add Friend</p>
</div>
<?php endif;?>
LastMitch
Industrious Poster
4,212 posts since Mar 2012
Reputation Points: 134
Solved Threads: 336
Skill Endorsements: 45

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0773 seconds using 2.72MB