Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- id | email | full_name | job_title | bio | profile_photo
- image_id | id | artist_img
- <?php
- $db = dbconnect();
- $stmt = $db->prepare('SELECT
- users.email,
- users.full_name,
- users.job_title,
- users.bio,
- users.profile_photo,
- images.id,
- images.artist_img
- FROM users
- INNER JOIN images ON users.id=images.id GROUP BY images.id');
- $stmt->execute();
- $result = $stmt->get_result();
- while (($row = mysqli_fetch_assoc($result)) != false) {
- $id = $row['id'];
- $full_name = $row['full_name'];
- $email = $row['email'];
- $job_title = $row['job_title'];
- $bio = $row['bio'];
- $ProfilePhoto = $row['profile_photo'];
- $artist_img = $row['artist_img'];
- if (isset($ProfilePhoto) && ! empty($ProfilePhoto)) {
- $image = "$ProfilePhoto";
- } else {
- $image = "avatar.jpg";
- }
- echo "<div class='container team-wrap'>
- <div class='row'>
- <div class='col-md-6'>
- <img class='img-responsive' src='artist/$image'>
- </div>
- <div class="col-md-6">
- <strong>$full_name<br>$job_title</strong>
- <br>
- <p>$bio</p>
- <a href='mailto:$email' class='btn btn-info'>Contact Me</a>
- </div>
- </div>
- </div>
- <div class="container space team-wrap">
- <div class="row">
- <div class="col-lg-12">
- <div id="gallery-slider" class="slider responsive">
- <div>";
- echo"
- <img src="gallery/$artist_img" alt=""></a>";
- echo "</div>
- </div>
- <hr>
- </div>
- </div>
- </div>";
- }
- ?>
- echo"<img src="gallery/$artist_img" alt=""></a>";
- SELECT * FROM `users` LEFT JOIN `images` ON images.id = users.id
- $users = [];
- foreach($results as $row){
- if(isset($users[$row->userId]))
- $users[$row->userId][] = $row->imageUrl;
- else
- $users[$row->userId] = [$row->imageUrl];
- }
- SELECT t.id,t.email,t.fullname,t2.image_id,t2.picture_name FROM table2 t LEFT JOIN table1 ON t2.id=t.id
- ------------------------------------------
- id | email | full_name
- ------------------------------------------
- 1 | test1@gmail.com | test1
- 2 | test2@gmail.com | test2
- 3 | test3@gmail.com | test3
- ------------------------------------------
- image id | id | picture_image
- ------------------------------------------
- 1 | 1 | image1.jpg
- 2 | 1 | image2.jpg
- 3 | 1 | image3.jpg
- 4 | 1 | image4.jpg
- 5 | 1 | image5.jpg
- 6 | 1 | image6.jpg
- 7 | 1 | image7.jpg
- 8 | 1 | image1.jpg
- 9 | 1 | image2.jpg
- 10 | 1 | image3.jpg
- 11 | 1 | image4.jpg
- 12 | 1 | image5.jpg
- SELECT * FROM users
- INNER JOIN images
- ON (users.id = images.id)
- WHERE (images.id = '1')
- SELECT * FROM `users` LEFT JOIN `images` ON images.id = users.id
- $result = $stmt->get_result();
- $users = array();
- foreach($results as $row){
- if (in_array($row['id'], $users)) {
- echo "Print profil picture";
- } else {
- array_push($users, $row['id']);
- echo "Print the other pictures";
- }
- }
- SELECT * FROM
- users
- INNER JOIN images on users.id = images.id
- INNER JOIN (SELECT MAX(image_id) as maxid, id from images GROUP BY id) as g
- ON images.image_id = g.maxid
- SELECT * FROM `users` LEFT JOIN `images` ON images.id = users.id
- $result = $stmt->get_result();
- $profile=$result[0]['id'] // initialise
- $imgs=array(); // inititalise
- foreach($result AS $row)
- {
- if($profile!=$row['id'])
- {
- $profile= $row['id'];
- echo "<div class='container team-wrap'>
- <div class='row'>
- <div class='col-md-6'>
- <img class='img-responsive' src='$image'>
- </div>
- <div class="col-md-6">
- <strong>$full_name<br>$job_title</strong>
- <br>
- <p>$bio</p>
- <a href='mailto:$email' class='btn btn-info'>Contact Me</a>
- </div>
- </div>
- </div>";
- echo "<div class="container space team-wrap">
- <div class="row">
- <div class="col-lg-12">
- <div id="gallery-slider" class="slider responsive">
- <div>";
- foreach($imgs AS $img)
- {
- echo "<a target="_blank" href="$img">
- <img src="$img" alt=""></a>";
- }
- $imgs=array(); // Empty out image array
- echo " </div>
- </div>
- </div>
- </div>
- <hr>
- </div>";
- }
- $full_name = $row['full_name'];
- $email = $row['email'];
- $job_title = $row['job_title'];
- $bio = $row['bio'];
- $ProfilePhoto = $row['profile_photo'];
- if (isset($ProfilePhoto) && ! empty($ProfilePhoto)) {
- $image = "$ProfilePhoto";
- } else {
- $image = "avatar.jpg";
- }
- if($row['artist_img']!==NULL)
- {
- $imgs[]= $row['artist_img'];
- }
- }
- /* Catch last one */
- $full_name = $row['full_name'];
- $email = $row['email'];
- $job_title = $row['job_title'];
- $bio = $row['bio'];
- $ProfilePhoto = $row['profile_photo'];
- if (isset($ProfilePhoto) && ! empty($ProfilePhoto)) {
- $image = "$ProfilePhoto";
- } else {
- $image = "avatar.jpg";
- }
- echo "<div class='container team-wrap'>
- <div class='row'>
- <div class='col-md-6'>
- <img class='img-responsive' src='$image'>
- </div>
- <div class="col-md-6">
- <strong>$full_name<br>$job_title</strong>
- <br>
- <p>$bio</p>
- <a href='mailto:$email' class='btn btn-info'>Contact Me</a>
- </div>
- </div>
- </div>";
- echo "<div class="container space team-wrap">
- <div class="row">
- <div class="col-lg-12">
- <div id="gallery-slider" class="slider responsive">
- <div>";
- foreach($imgs AS $img)
- {
- echo "<a target="_blank" href="$img">
- <img src="$img" alt="">
- </a>";
- }
- echo " </div>
- </div>
- </div>
- </div>
- <hr>
- </div>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement