Jump to content

Recommended Posts

I want to fetch data from a table let's say  table "activities". 

Uid | day | activity | time | remarks

1.     Mon.    Act1.      3pm.    Good

2.    Mon.     Act1.      5pm.     Bad

1.    Tue.      Act2.      12am.   Bad

1.   Tue.       Act5.      1am.     Bad

1.   Thur.     Act8.       9pm.    Good 

2.   Wed.     Act4.      7am.     Good

 

Now assuming I want to fetch all the data that is related to user Id 1 and display them in another table (Uid 1).  

Which is 4 rows according to the table, how do I go about it using select query?   Thanks!!!

I tried something like this but it displays just one row

<?php

$uid = $_SESSION['login'];

$sql2 = "SELECT * FROM Activities WHERE uid=? ORDER BY Uid LIMIT 6";
$stmt2 = $connection->prepare($sql2); 
$stmt2->bind_param('i', $Uid);
$stmt2->execute();
$result2 = $stmt2->get_result();
$row2 = $result2->fetch_assoc();

//now am stuck here
 ?>

now trying to display the fetch those data for only Uid 1 in these simple format...

 

<table style="width:100%">
  <tr>
    <th>Day</th>
    <th>Activity</th>
    <th>Remarks</th>
  </tr>
  <tr>
    <td>Mon</td>
    <td>Act1</td>
    <td>Good</td>
  </tr>
  <tr>
    <td>Tue</td>
    <td>Act2</td>
    <td>Bad</td>
  </tr>

<tr>
    <td>Tue</td>
    <td>Act5</td>
    <td>Bad</td>
  </tr>
</table>


   Jus like that, to contain all the 4 data for Uid 1. Thanks in advance..

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/311130-how-do-i-display-all-the-data-of-a-user/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.