Social Networking Site: Facebook like “Discover People You May Know”
Submitted by GeePee on Friday, March 20, 2015 - 16:26.
In this tutorial, I’m going to show you how to create page Facebook like “Discover People You May Know”. This page will display a list of all people you may know or you want to know and this page also is a preparation for our next lesson on how to add friends. To start in this lesson, open a “home.php” file, then under the first “
After adding the code above, the home will now look like as shown below.
Then we will do the same process to all our pages, example for the gallery, here’s all the code of our gallery.php file.
And the photo gallery will now look like as shown below.
At this time, we’re going to create a new PHP file called “addfriend.php”. This page will show if the user wants to find a new friend the user can click the “Friends you may know”option. And here’s the following code for “addfriend.php” file.
And this will now look like as shown below.
If you want to see more of my works, new Source Code or Application and Tutorials Just click here.
”, change the first div
into this following code.
This code below will also display some basic information of a user, and we have also added a new option under “View Photos” which is a “Friends You May Know” and this option when access will show the page of “Discover People You May Know”. And we have also added a panel below the Basic Information panel that will be used for a list of our friends.
- <div class="col-xs-6 col-md-3">
- <a data-target="#myModal" data-toggle="modal" href="" title=
- "Click here to Change Image.">
- <?php
- $mydb->setQuery("SELECT * FROM photos WHERE `member_id`='{$_SESSION['member_id']}' and `pri`='yes'");
- $cur = $mydb->loadResultList();
- if ($mydb->affected_rows()== 0){
- echo '<img src="./uploads/p.jpg" class="img-thumbnail"/>';
- }
- foreach($cur as $object){
- echo '<img src="./uploads/'. $object->filename.'" class="img-thumbnail" />';
- }
- ?>
- </a>
- <!-- Modal -->
- <div class="modal fade" id="myModal" tabindex="-1">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <button class="close" data-dismiss="modal" type=
- "button">×</button>
- <h4 class="modal-title" id="myModalLabel">Choose Your best
- picture for your Profile.</h4>
- </div>
- <form action="save_photo.php" enctype="multipart/form-data" method=
- "post">
- <div class="modal-body">
- <div class="form-group">
- <div class="rows">
- <div class="col-md-12">
- <div class="rows">
- <div class="col-md-8">
- <input name="MAX_FILE_SIZE" type=
- "hidden" value="1000000"> <input id=
- "upload_file" name="upload_file" type=
- "file">
- </div>
- <div class="col-md-4"></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <button class="btn btn-default" data-dismiss="modal" type=
- "button">Close</button> <button class="btn btn-primary"
- name="savephoto" type="submit">Save Photo</button>
- </div>
- </form>
- </div><!-- /.modal-content -->
- </div><!-- /.modal-dialog -->
- </div><!-- /.modal -->
- <div class="list-group">
- <a href="gallery.php" class="list-group-item">
- <span class="badge pull-right">
- <?php $mydb->setQuery("SELECT * FROM photos WHERE `member_id`='{$_SESSION['member_id']}'");
- $cur = $mydb->executeQuery();
- echo $row_count = $mydb->num_rows($cur);
- ?>
- </span>
- View photos
- </a>
- <a href="addfriend.php" class="list-group-item">
- <span class="badge pull-right">
- <?php $mydb->setQuery("SELECT * FROM user_info");
- $cur = $mydb->executeQuery();
- echo $row_count = $mydb->num_rows($cur);
- ?>
- </span>
- Friends you may know
- </a>
- </div>
- <div class="panel panel-success">
- <?php
- $mydb->setQuery("Select * from basic_info where member_id=".$_SESSION['member_id']);
- $info = $mydb->loadSingleResult();
- ?>
- <div class="panel-heading"><h3 class="panel-title">Information</h3></div>
- <div class="panel-body">
- <p class="text-muted">Networks:</p> <p><?php echo $info->networks; ?></p>
- <p class="text-muted">Relationship Status:</p><p><?php echo $info->rel_stats; ?></p>
- <p class="text-muted">Birthday:</p> <p><?php echo bdate_toText($_SESSION['bday']); ?></p>
- </div>
- </div>
- <div class="panel panel-default">
- <div class="panel-heading"> <h3 class="panel-title">Friends</h3></div>
- <div class="panel-body">
- <?php
- $mydb->setQuery("Select * from user_info ");
- $cur = $mydb->loadResultList();
- foreach($cur as $object):
- ?>
- <?php endforeach;?>
- </div>
- </div>
- </div>
- <?php
- require_once("includes/initialize.php");
- include 'header.php';
- ?>
- <div class="container">
- <div class="well">
- <div class="row">
- <div class="col-xs-6 col-md-3">
- <a data-target="#myModal" data-toggle="modal" href="" title=
- "Click here to Change Image.">
- <?php
- $mydb->setQuery("SELECT * FROM photos WHERE `member_id`='{$_SESSION['member_id']}' and `pri`='yes'");
- $cur = $mydb->loadResultList();
- if ($mydb->affected_rows()== 0){
- echo '<img src="./uploads/p.jpg" class="img-thumbnail"/>';
- }
- foreach($cur as $object){
- echo '<img src="./uploads/'. $object->filename.'" class="img-thumbnail" />';
- }
- ?>
- </a>
- <!-- Modal -->
- <div class="modal fade" id="myModal" tabindex="-1">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <button class="close" data-dismiss="modal" type=
- "button">×</button>
- <h4 class="modal-title" id="myModalLabel">Choose Your best
- picture for your Profile.</h4>
- </div>
- <form action="save_photo.php" enctype="multipart/form-data" method=
- "post">
- <div class="modal-body">
- <div class="form-group">
- <div class="rows">
- <div class="col-md-12">
- <div class="rows">
- <div class="col-md-8">
- <input name="MAX_FILE_SIZE" type=
- "hidden" value="1000000"> <input id=
- "upload_file" name="upload_file" type=
- "file">
- </div>
- <div class="col-md-4"></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <button class="btn btn-default" data-dismiss="modal" type=
- "button">Close</button> <button class="btn btn-primary"
- name="savephoto" type="submit">Save Photo</button>
- </div>
- </form>
- </div><!-- /.modal-content -->
- </div><!-- /.modal-dialog -->
- </div><!-- /.modal -->
- <div class="list-group">
- <a href="gallery.php" class="list-group-item active">
- <span class="badge pull-right">
- <?php $mydb->setQuery("SELECT * FROM photos WHERE `member_id`='{$_SESSION['member_id']}'");
- $cur = $mydb->executeQuery();
- echo $row_count = $mydb->num_rows($cur);
- ?>
- </span>
- View photos
- </a>
- <a href="addfriend.php" class="list-group-item">
- <span class="badge pull-right">
- <?php $mydb->setQuery("SELECT * FROM user_info");
- $cur = $mydb->executeQuery();
- echo $row_count = $mydb->num_rows($cur);
- ?>
- </span>
- Friends you may know
- </a>
- </div>
- <div class="panel panel-success">
- <?php
- $mydb->setQuery("Select * from basic_info where member_id=".$_SESSION['member_id']);
- $info = $mydb->loadSingleResult();
- ?>
- <div class="panel-heading"><h3 class="panel-title">Information</h3></div>
- <div class="panel-body">
- <p class="text-muted">Networks:</p> <p><?php echo $info->networks; ?></p>
- <p class="text-muted">Relationship Status:</p><p><?php echo $info->rel_stats; ?></p>
- <p class="text-muted">Birthday:</p> <p><?php echo bdate_toText($_SESSION['bday']); ?></p>
- </div>
- </div>
- <div class="panel panel-default">
- <div class="panel-heading"> <h3 class="panel-title">Friends</h3></div>
- <div class="panel-body">
- <?php
- $mydb->setQuery("Select * from user_info ");
- $cur = $mydb->loadResultList();
- foreach($cur as $object):
- ?>
- <?php endforeach;?>
- </div>
- </div>
- </div>
- <div class="col-xs-12 col-sm-6 col-md-8">
- <div class="panel panel-default">
- <div class="panel-heading"><h3 class="panel-title">List of Photos</h3></div>
- <div class="panel-body">
- <?php
- $mydb->setQuery("SELECT * FROM photos WHERE `member_id`='{$_SESSION['member_id']}'");
- $cur = $mydb->loadResultList();
- foreach($cur as $object): ?>
- <a data-target="#myModall" data-toggle="modal" >
- <img src="./uploads/<?php echo $object->filename; ?> " class="img-thumbnail" width="200" height="200" />
- </a>
- <?php endforeach;?>
- <!-- Modal -->
- <div class="modal fade" id="myModall" tabindex="-1">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-body">
- </div>
- </div><!-- /.modal-content -->
- </div><!-- /.modal-dialog -->
- </div><!-- /.modal -->
- </div>
- </div>
- </div>
- </div> <!-- /container -->
- <footer>
- <p align="center">© Philsocial 2013</p>
- </footer>
- <!-- Bootstrap core JavaScript
- ================================================== -->
- <!-- Placed at the end of the document so the pages load faster -->
- <script src="js/tooltip.js"></script>
- <script src="assets/js/jquery.js"></script>
- <script src="js/bootstrap.min.js"></script>
- <script src="js/popover.js"></script>
- <script>
- $(document).ready(function(){
- $('a img').on('click',function(){
- var src = $(this).attr('src');
- var image = '<img src="' + src + '" class="img-responsive"/>';
- $('#myModall').modal();
- $('#myModall').on('shown.bs.modal', function(){
- $('#myModall .modal-body').html(image);
- });
- $('#myModall').on('hidden.bs.modal', function(){
- $('#myModall .modal-body').html('');
- });
- });
- })
- </script>
- </body>
- </html>
- <?php
- require_once("includes/initialize.php");
- include 'header.php';
- ?>
- <div class="container">
- <div class="well">
- <div class="row">
- <div class="col-xs-6 col-md-3">
- <a data-target="#myModal" data-toggle="modal" href="" title=
- "Click here to Change Image.">
- <?php
- $mydb->setQuery("SELECT * FROM photos WHERE `member_id`='{$_SESSION['member_id']}' and `pri`='yes'");
- $cur = $mydb->loadResultList();
- if ($mydb->affected_rows()== 0){
- echo '<img src="./uploads/p.jpg" class="img-thumbnail"/>';
- }
- foreach($cur as $object){
- echo '<img src="./uploads/'. $object->filename.'" class="img-thumbnail" />';
- }
- ?>
- </a>
- <!-- Modal -->
- <div class="modal fade" id="myModal" tabindex="-1">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <button class="close" data-dismiss="modal" type=
- "button">×</button>
- <h4 class="modal-title" id="myModalLabel">Choose Your best
- picture for your Profile.</h4>
- </div>
- <form action="save_photo.php" enctype="multipart/form-data" method=
- "post">
- <div class="modal-body">
- <div class="form-group">
- <div class="rows">
- <div class="col-md-12">
- <div class="rows">
- <div class="col-md-8">
- <input name="MAX_FILE_SIZE" type=
- "hidden" value="1000000"> <input id=
- "upload_file" name="upload_file" type=
- "file">
- </div>
- <div class="col-md-4"></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <button class="btn btn-default" data-dismiss="modal" type=
- "button">Close</button> <button class="btn btn-primary"
- name="savephoto" type="submit">Save Photo</button>
- </div>
- </form>
- </div><!-- /.modal-content -->
- </div><!-- /.modal-dialog -->
- </div><!-- /.modal -->
- <div class="list-group">
- <a href="gallery.php" class="list-group-item ">
- <span class="badge pull-right">
- <?php $mydb->setQuery("SELECT * FROM photos WHERE `member_id`='{$_SESSION['member_id']}'");
- $cur = $mydb->executeQuery();
- echo $row_count = $mydb->num_rows($cur);
- ?>
- </span>
- View photos
- </a>
- <a href="gallery.php" class="list-group-item active" >
- <span class="badge pull-right">
- <?php $mydb->setQuery("SELECT * FROM user_info");
- $cur = $mydb->executeQuery();
- echo $row_count = $mydb->num_rows($cur);
- ?>
- </span>
- Friends you may know
- </a>
- </div>
- <div class="panel panel-success">
- <?php
- $mydb->setQuery("Select * from basic_info where member_id=".$_SESSION['member_id']);
- $info = $mydb->loadSingleResult();
- ?>
- <div class="panel-heading"><h3 class="panel-title">Information</h3></div>
- <div class="panel-body">
- <p class="text-muted">Networks:</p> <p><?php echo $info->networks; ?></p>
- <p class="text-muted">Relationship Status:</p><p><?php echo $info->rel_stats; ?></p>
- <p class="text-muted">Birthday:</p> <p><?php echo bdate_toText($_SESSION['bday']); ?></p>
- </div>
- </div>
- <div class="panel panel-default">
- <div class="panel-heading"> <h3 class="panel-title">Friends</h3></div>
- <div class="panel-body">
- <?php
- $mydb->setQuery("Select * from user_info ");
- $cur = $mydb->loadResultList();
- foreach($cur as $object):?>
- <?php endforeach;?>
- </div>
- </div>
- </div>
- <div class="col-xs-12 col-sm-6 col-md-8">
- <h3 class="text-primary">Discover People You May Know</h3>
- <div class="panel panel-default">
- <div class="panel-body">
- <?php
- $mydb->setQuery("SELECT *
- FROM `user_info`
- WHERE `member_id` !='{$_SESSION['member_id']}'");
- $cur = $mydb->loadResultList();
- foreach($cur as $info):
- $mydb->setQuery("SELECT * FROM photos WHERE `member_id`=".$info->member_id ."
- AND `member_id`!='{$_SESSION['member_id']}' and `pri`='yes'");
- $pho = $mydb->loadResultList();
- ?>
- <p class="pull-left">
- <?php
- if ($mydb->affected_rows()== 0){
- echo '<a href="#">';
- echo '<img src="./uploads/p.jpg" class="img-thumbnail" width="140" height="120"/>';
- echo '</a>';
- }
- foreach($pho as $object){
- echo '<a href="#">';
- echo '<img src="./uploads/'. $object->filename.'" class="img-thumbnail" width="140" height="120" />';
- echo '</a>';
- }
- ?>
- <br/>
- <strong><?php echo $info->fName. ' ' .$info->lName;?></strong><br/><a>Add as Friend</a></p>
- <?php endforeach;?>
- </div>
- </dl>
- </div>
- </div>
- </body>
- </html>
- <hr>
- </div> <!-- /container -->
- <footer>
- <p align="center">© Philsocial 2013</p>
- </footer>
- <!-- Bootstrap core JavaScript
- ================================================== -->
- <!-- Placed at the end of the document so the pages load faster -->
- <script src="js/tooltip.js"></script>
- <script src="assets/js/jquery.js"></script>
- <script src="js/bootstrap.min.js"></script>
- <script src="js/popover.js"></script>
- </body>
- </html>
Add new comment
- 792 views