Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.50 KB | None | 0 0
  1. id | email | full_name | job_title | bio | profile_photo
  2.  
  3. image_id | id | artist_img
  4.  
  5. <?php
  6.  
  7. $db = dbconnect();
  8. $stmt = $db->prepare('SELECT
  9. users.email,
  10. users.full_name,
  11. users.job_title,
  12. users.bio,
  13. users.profile_photo,
  14. images.id,
  15. images.artist_img
  16. FROM users
  17. INNER JOIN images ON users.id=images.id GROUP BY images.id');
  18. $stmt->execute();
  19. $result = $stmt->get_result();
  20.  
  21. while (($row = mysqli_fetch_assoc($result)) != false) {
  22.  
  23. $id = $row['id'];
  24. $full_name = $row['full_name'];
  25. $email = $row['email'];
  26. $job_title = $row['job_title'];
  27. $bio = $row['bio'];
  28. $ProfilePhoto = $row['profile_photo'];
  29. $artist_img = $row['artist_img'];
  30.  
  31.  
  32. if (isset($ProfilePhoto) && ! empty($ProfilePhoto)) {
  33. $image = "$ProfilePhoto";
  34. } else {
  35. $image = "avatar.jpg";
  36. }
  37.  
  38. echo "<div class='container team-wrap'>
  39. <div class='row'>
  40. <div class='col-md-6'>
  41. <img class='img-responsive' src='artist/$image'>
  42. </div>
  43. <div class="col-md-6">
  44. <strong>$full_name<br>$job_title</strong>
  45. <br>
  46. <p>$bio</p>
  47. <a href='mailto:$email' class='btn btn-info'>Contact Me</a>
  48. </div>
  49. </div>
  50. </div>
  51.  
  52. <div class="container space team-wrap">
  53. <div class="row">
  54. <div class="col-lg-12">
  55. <div id="gallery-slider" class="slider responsive">
  56. <div>";
  57.  
  58.  
  59.  
  60.  
  61. echo"
  62. <img src="gallery/$artist_img" alt=""></a>";
  63.  
  64.  
  65.  
  66.  
  67. echo "</div>
  68. </div>
  69. <hr>
  70. </div>
  71. </div>
  72. </div>";
  73. }
  74. ?>
  75.  
  76. echo"<img src="gallery/$artist_img" alt=""></a>";
  77.  
  78. SELECT * FROM `users` LEFT JOIN `images` ON images.id = users.id
  79.  
  80. $users = [];
  81. foreach($results as $row){
  82. if(isset($users[$row->userId]))
  83. $users[$row->userId][] = $row->imageUrl;
  84.  
  85. else
  86. $users[$row->userId] = [$row->imageUrl];
  87. }
  88.  
  89. SELECT t.id,t.email,t.fullname,t2.image_id,t2.picture_name FROM table2 t LEFT JOIN table1 ON t2.id=t.id
  90.  
  91. ------------------------------------------
  92. id | email | full_name
  93. ------------------------------------------
  94. 1 | test1@gmail.com | test1
  95. 2 | test2@gmail.com | test2
  96. 3 | test3@gmail.com | test3
  97.  
  98. ------------------------------------------
  99. image id | id | picture_image
  100. ------------------------------------------
  101. 1 | 1 | image1.jpg
  102. 2 | 1 | image2.jpg
  103. 3 | 1 | image3.jpg
  104. 4 | 1 | image4.jpg
  105. 5 | 1 | image5.jpg
  106. 6 | 1 | image6.jpg
  107. 7 | 1 | image7.jpg
  108. 8 | 1 | image1.jpg
  109. 9 | 1 | image2.jpg
  110. 10 | 1 | image3.jpg
  111. 11 | 1 | image4.jpg
  112. 12 | 1 | image5.jpg
  113.  
  114. SELECT * FROM users
  115. INNER JOIN images
  116. ON (users.id = images.id)
  117. WHERE (images.id = '1')
  118.  
  119. SELECT * FROM `users` LEFT JOIN `images` ON images.id = users.id
  120.  
  121. $result = $stmt->get_result();
  122.  
  123. $users = array();
  124. foreach($results as $row){
  125.  
  126. if (in_array($row['id'], $users)) {
  127. echo "Print profil picture";
  128. } else {
  129. array_push($users, $row['id']);
  130. echo "Print the other pictures";
  131. }
  132. }
  133.  
  134. SELECT * FROM
  135. users
  136. INNER JOIN images on users.id = images.id
  137. INNER JOIN (SELECT MAX(image_id) as maxid, id from images GROUP BY id) as g
  138. ON images.image_id = g.maxid
  139.  
  140. SELECT * FROM `users` LEFT JOIN `images` ON images.id = users.id
  141.  
  142. $result = $stmt->get_result();
  143. $profile=$result[0]['id'] // initialise
  144. $imgs=array(); // inititalise
  145. foreach($result AS $row)
  146. {
  147. if($profile!=$row['id'])
  148. {
  149. $profile= $row['id'];
  150.  
  151. echo "<div class='container team-wrap'>
  152. <div class='row'>
  153. <div class='col-md-6'>
  154. <img class='img-responsive' src='$image'>
  155. </div>
  156. <div class="col-md-6">
  157. <strong>$full_name<br>$job_title</strong>
  158. <br>
  159. <p>$bio</p>
  160. <a href='mailto:$email' class='btn btn-info'>Contact Me</a>
  161. </div>
  162. </div>
  163. </div>";
  164.  
  165.  
  166. echo "<div class="container space team-wrap">
  167. <div class="row">
  168. <div class="col-lg-12">
  169. <div id="gallery-slider" class="slider responsive">
  170. <div>";
  171.  
  172.  
  173. foreach($imgs AS $img)
  174. {
  175. echo "<a target="_blank" href="$img">
  176. <img src="$img" alt=""></a>";
  177. }
  178. $imgs=array(); // Empty out image array
  179.  
  180. echo " </div>
  181. </div>
  182. </div>
  183. </div>
  184. <hr>
  185. </div>";
  186.  
  187. }
  188.  
  189.  
  190. $full_name = $row['full_name'];
  191. $email = $row['email'];
  192. $job_title = $row['job_title'];
  193. $bio = $row['bio'];
  194. $ProfilePhoto = $row['profile_photo'];
  195. if (isset($ProfilePhoto) && ! empty($ProfilePhoto)) {
  196. $image = "$ProfilePhoto";
  197. } else {
  198. $image = "avatar.jpg";
  199. }
  200.  
  201. if($row['artist_img']!==NULL)
  202. {
  203. $imgs[]= $row['artist_img'];
  204. }
  205.  
  206.  
  207. }
  208. /* Catch last one */
  209.  
  210. $full_name = $row['full_name'];
  211. $email = $row['email'];
  212. $job_title = $row['job_title'];
  213. $bio = $row['bio'];
  214. $ProfilePhoto = $row['profile_photo'];
  215. if (isset($ProfilePhoto) && ! empty($ProfilePhoto)) {
  216. $image = "$ProfilePhoto";
  217. } else {
  218. $image = "avatar.jpg";
  219. }
  220.  
  221. echo "<div class='container team-wrap'>
  222. <div class='row'>
  223. <div class='col-md-6'>
  224. <img class='img-responsive' src='$image'>
  225. </div>
  226. <div class="col-md-6">
  227. <strong>$full_name<br>$job_title</strong>
  228. <br>
  229. <p>$bio</p>
  230. <a href='mailto:$email' class='btn btn-info'>Contact Me</a>
  231. </div>
  232. </div>
  233. </div>";
  234.  
  235.  
  236. echo "<div class="container space team-wrap">
  237. <div class="row">
  238. <div class="col-lg-12">
  239. <div id="gallery-slider" class="slider responsive">
  240. <div>";
  241. foreach($imgs AS $img)
  242. {
  243. echo "<a target="_blank" href="$img">
  244. <img src="$img" alt="">
  245. </a>";
  246. }
  247.  
  248. echo " </div>
  249. </div>
  250. </div>
  251. </div>
  252. <hr>
  253. </div>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement