1,105,331 Community Members

I need help in php view page display records

Member Avatar
Vijaysurya
Light Poster
35 posts since Jan 2012
Reputation Points: -2 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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;?>
LastMitch
Deleted Member
 
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.

Member Avatar
Vijaysurya
Light Poster
35 posts since Jan 2012
Reputation Points: -2 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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;?>
LastMitch
Deleted Member
 
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?

Member Avatar
Vijaysurya
Light Poster
35 posts since Jan 2012
Reputation Points: -2 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

LastMitch
Deleted Member
 
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;?>
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article