Ok I have the following SQL Query:
Each video has a special id. The points will tell you which video you watched based on the special matching on points and videos
Each book has a token . The video is told which video to go on based on the token .
--
What I want to do? I want to have a page that displays the point value aa user has used.
I have tried to do this code:
$one = $db->query("SELECT * FROM points WHERE user='$user' GROUP BY book");
while($fetch_data = mysqli_fetch_array($one)) {
$special = $fetch_data["special"];
$points = $fetch_data["points"];
$type = $fetch_data["type"];
$date = $fetch_data["date"];
// FIND BOOK
$two = $db->query("SELECT * FROM videos WHERE special='$special'");
while($fetch_data2 = mysqli_fetch_array($two)) {
$title = $fetch_data2["title"];
// At this point echo output
}
}
Use inner join to fetch the data from videos and points and loop through the result
$query = $db->query("Select a.*,b.* from points a inner join videos b on a.special = b.special where a.user = '$user'")
while ($result = mysqli_fetch_array($query){
//echo the output
}
use INNER JOIN
no need multiple query
"SELECT p.*,v.* FROM points as p
inner join videos as v
on v.special =p.special
WHERE p.user='".$user."'
group by p.books"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.