close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Filter record base on user and show their status

Thread began 7/15/2021 12:16 am by Rokon | Last modified 7/20/2021 9:48 am by Ray Borduin | 66 views | 8 replies |

Rokon

Filter record base on user and show their status

Hello

I am having a problem which as below and requesting for help.


I have a website where many books content are there. I also have a usergroup who come here to read the books and then base on their choice by using the login system they can make any books content favorite or non favorite etc, so that next time when they comes back and login they can find their previous favorite content. Note that I am storing their favorite contentID in a seperate table.

Now I need to present always to a user with all the books content and only a mark ❤️ will show beside the content that this contentID is in their favorite list and others are not in his favorite list by showing another ❤ .

The problem arise when a user loged in and visit to the page then it shows only the filtered favorite ❤️ datas based on their userID and not showing others non favorite content. I need to present always full content list (favorite and non favorite data of the user) to every user which will show which one is in favorite and which one not, but how to make the joint table query for showing the full content for every seperate user I am lost here. Please guide me.

Below is an example of the tables;


Content Table
==========
contentID
content


User Table
=======
userID
username
userpass


Favorite Table
==========
favID
userID
contentID

Sign in to reply to this post

Ray BorduinWebAssist

You probably just need to use a LEFT OUTER JOIN instead of an INNER JOIN on the favorites table.

Sign in to reply to this post
Did this help? Tips are appreciated...

Rokon

I have tried in several way and it seems always the result is coming fully filtered which is only few record as per the users. Attach is the query and the picutre in query builder.

<?php
$useractivity = new WA_MySQLi_RS("useractivity",$hadithbd,20);
$useractivity->setQuery("SELECT users.UserID, users.UserEmail, activity_user.activityID, activity_user.userid, activity_user.itemGroup, activity_user.itemType, activity_user.itemID, hadithmain.HadithID FROM users LEFT OUTER JOIN activity_user ON users.UserID = activity_user.userid LEFT OUTER JOIN hadithmain ON activity_user.itemID = hadithmain.HadithID WHERE users.UserID = ?");
$useractivity->bindParam("i", "".(isset($_SESSION['UserID'])?$_SESSION['UserID']:"") ."", "-1"); //WAQB_Param1
$useractivity->execute();
?>

Sign in to reply to this post

Ray BorduinWebAssist

Which table did you want all of the results from? It should be the first table listed in your query.

Sign in to reply to this post
Did this help? Tips are appreciated...

Rokon

The main content table name is hadithmain from where all the data need to show always

Sign in to reply to this post

Ray BorduinWebAssist

Try:

SELECT users.UserID, users.UserEmail, activity_user.activityID, activity_user.userid, activity_user.itemGroup, activity_user.itemType, activity_user.itemID, hadithmain.HadithID
FROM hadithmain
LEFT OUTER JOIN activity_user ON activity_user.itemID = hadithmain.HadithID AND activity_user.userid = ?
LEFT OUTER JOIN users ON users.UserID = activity_user.userid

Sign in to reply to this post
Did this help? Tips are appreciated...

Rokon

It shows an error like attachment

Sign in to reply to this post

Ray BorduinWebAssist

Try it without the editor... The sql statement might be too complex for the editor.

Sign in to reply to this post
Did this help? Tips are appreciated...

Rokon

Unfortunately that didn't work for me rather I find out another way where instead of joing table query I show/hide base on matching from the parent table and it solved my problem. Thanks for your support.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...