Social Networking Site: Loading the User Basic Information

This tutorial, is a continuation of our previous topic called “Social Networking Site saving basic Information”. But this time we’re going to focus on how to load all the save information from the database. And it looks like as shown below: To start with this tutorial, open our project folder and select the file called “info.php”. Then under end portion of the Modal, add the following code: This code below will search all the user information from the database table called “basic_info” and using the loadSingleResult method it loads the single result to $info variable.
  1. <?php
  2. $mydb->setQuery("Select * from basic_info where member_id=".$_SESSION['member_id']);
  3. $info = $mydb->loadSingleResult();
  4.  
  5. ?>
Then, since our $info variable is now holding a value. We are now ready to load the specific value to each user basic information. And here’s the following code: This portion using the $info variable we specify the specific object to load the data from the database.
  1. <div class="form-inline">
  2. <div class="rows">
  3. <div class="col-md-12">
  4. <div class="col-md-4" id="Networks">
  5. <h5>Networks :</h5>
  6. </div>
  7. <div class="col-md-8">
  8. //it loads the network information from the database
  9. <h5><a><?php echo $info->networks; ?></a></h5>
  10. </div>
  11.  
  12. </div>
  13. </div>
  14. </div>
  15.  
  16. <div class="form-inline">
  17. <div class="rows">
  18. <div class="col-md-12">
  19. <div class="col-md-4" id="gender">
  20. <h5>Gender :</h5>
  21. </div>
  22. <div class="col-md-8">
  23. //it loads the gender information using the session variable from the database
  24. <h5><a><?php echo $_SESSION['gender']; ?></a></h5>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29.  
  30. <div class="form-inline">
  31. <div class="rows">
  32. <div class="col-md-12">
  33. <div class="col-md-4" id="bday">
  34. <h5>Birth Day :</h5>
  35. </div>
  36. <div class="col-md-8">
  37. <h5><a><?php echo $_SESSION['bday']; ?></a></h5>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42.  
  43. <div class="form-inline">
  44. <div class="rows">
  45. <div class="col-md-12">
  46. <div class="col-md-4" id="interest">
  47. <h5>Interested In:</h5>
  48. </div>
  49. <div class="col-md-8">
  50. //it loads the interest information from the database
  51. <h5><a><?php echo $info->interested_in; ?></a></h5>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56.  
  57. <div class="form-inline">
  58. <div class="rows">
  59. <div class="col-md-12">
  60. <div class="col-md-4" id="relstats">
  61. <h5>Relationship Status :</h5>
  62. </div>
  63. <div class="col-md-8">
  64. //it loads the relationship status information from the database
  65. <h5><a><?php echo $info->rel_stats; ?></a></h5>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70.  
  71. <div class="form-inline">
  72. <div class="rows">
  73. <div class="col-md-12">
  74. <div class="col-md-4" id="language">
  75. <h5>Language:</h5>
  76. </div>
  77. <div class="col-md-8">
  78. //it loads the language information from the database
  79. <h5><a><?php echo $info->language; ?></a></h5>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. <div class="form-inline">
  85. <div class="rows">
  86. <div class="col-md-12">
  87. <div class="col-md-4" id="religion">
  88. <h5>Religion:</h5>
  89. </div>
  90. <div class="col-md-8">
  91. //it loads the religion information from the database
  92. <h5><a><?php echo $info->religion; ?></a></h5>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97.  
  98. <div class="form-inline">
  99. <div class="rows">
  100. <div class="col-md-12">
  101. <div class="col-md-4" id="reldesc">
  102. <h5>Descriptions:</h5>
  103. </div>
  104. <div class="col-md-8">
  105. //it loads the religion description information from the database
  106. <h5><a><p><?php echo $info->rel_desc; ?><p></a></h5>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. <div class="form-inline">
  112. <div class="rows">
  113. <div class="col-md-12">
  114. <div class="col-md-4" id="politicalview">
  115. <h5>Political Views:</h5>
  116. </div>
  117. <div class="col-md-8">
  118. //it loads the political view information from the database
  119. <h5><a><?php echo $info->political_view; ?></a></h5>
  120. </div>
  121. </div>
  122. </div>
  123. </div>
  124.  
  125. <div class="form-inline">
  126. <div class="rows">
  127. <div class="col-md-12">
  128. <div class="col-md-4" id="poldesc">
  129. <h5>Descriptions:</h5>
  130. </div>
  131. <div class="col-md-8">
  132. //it loads the political view description information from the database
  133. <h5><a><p><?php echo $info->pol_desc; ?></p></a></h5>
  134. </div>
  135. </div>
  136. </div>
  137. </div>
And you can do this the same in the loading of Modal, when the user click the edit button for editing of basic information, the Modal should contain the current basic information about the user to be edited. I will leave this to you as your assignment.

Add new comment