I'm fairly new in making own code in concrete5, so I could use some help! :)
I have a reference table with event IDs and user IDs. I would like to fetch the names of all users on a givent event.
I have the two necessary IDs:
UserID: $u->getUserID();
EventID: $c->getCollectionID()
How can I make a loop in a view.php page, that creates a list of all names of the users signed up for an event? The name is in the user attribute "name".
Example: I would like to have the names of the users with user ID 1 and 4, because they have signed up for event 221 (see this image: http://www.tiikoni.com/tis/view/?id=11a89f6).
Expected result on my page: John Doe, Jane Doe
I hope someone can help me.
The image link has expired, as Ortomala replied.
Sounds like you need some custom PHP block code that SELECTs all user ids from the MySQL table that matches the EventID (the current UserID is not relevant).
Here's some example pseudo code:
"SELECT b.UserID, u.uName FROM btYourEventTable AS b, Users as u
WHERE EventID = '". $c->getCollectionID(). "' AND b.UserID = u.uID";
If you need help with this, I'm user jasteele12 on concrete5.org
Related
I want to create a form where the logged author can fill a textarea and then select 1 or more system users from a checkbox
So when every user logs in he Will see that record only if he has been selected in the checkbox before.
How can i do it?
Must i save values of the checkbox in a single record and then split to set the correct data set?
And then how can i show the whole records to the current user as i want him to see a list of records where he is the author or where he is among the users allowed to set that very same record
I know this can be a generic request but the matter is i dont understand how i could do it, so the answer i look for is not "give me the code" but"explain me the main steps i must follow", someone can give me some hints?
How about creating a table named "record" with the following structure:
id author_id allowed_user_id text
Now, when the author with id 1 selects two users with ids 2 and 3, you insert two rows into that table, one for each allowed user
id author_id allowed_user_id text
1 1 2 just a test
2 1 3 just a test
To show the current user the records he authored
SELECT * FROM record WHERE author_id = current_user_id
and records he's allowed
SELECT * FROM record WHERE allowed_user_id = current_user_id
MySQL code: jsfiddle.net/HBps8/
I have a table called "Likers", in that table, there is "ID, User FB ID, user FB name, and user Access Token".
At the moment, there are 2487 records in the "Likers" table.
(ID is the number of user, if the user submitted his access token when the table was EMPTIED; his ID will be 1, if another user submits his access token after the first user; his id will be 2 and so on and on)
The problem I am facing is that when the HTML form is submitted to get the IDs; it gets the OLDEST ids first (ID #1, #2, #3, #4, etc...)
What I want is that when the form is submitted, the RECENT ID's should be first (ID #2487, #2486, #2485, #2484, etc...)
Is it possible to do something like that in MySQL database? I am very new to the databases codes and I am trying my best to learn :)
Thanks in advance.
In your MySQL query you can use ORDER BY
For example
SELECT * FROM `Likers` ORDER BY `ID` DESC
you can sort the result by using ORDER BY, e.g. ORDER BY ID DESC. But it is not recommended to determine the latest entries by the ID, you should add a additional field like creationDate and sort by this one.
Okey, so im trying to store the logged in facebook userĀ“s friends list into a MYSQL table.
Im storing the logged in user data: ID and Name;
And am storing the logged in user friends list: ID and Name;
So the table looks like this:
['facebook_user_id'] ['facebook_user_name'] ['facebook_friend_id'] ['facebook_friend_name']
123123123123 User1 23424234234234 User 20
231321231231 User2 23424234234234 User 20
So you can see that user1 and user2 has the same friend and if user friend 'User 20' change his/her name I need to update the information, but only for the logged in user, so if user1 logs in the effect will only effect him/her.
But if user1 gets a new friend I need to insert the new friend and update if theres any changes.
How should I do this with PHP? I have seen something similar but didnt work that well for me.
INSERT INTO table (facebook_user_id, facebook_user_name, facebook_friend_id, facebook_friend_name)
VALUES ('facebook_user_id' (to short it down) .....)
ON DUPLICATE KEY UPDATE (facebook_user_id=facebook_user_id (and for every entry)....)
Thanks in advance, and any pointers will help me out alot.
I think this is what you meant.
I am trying to save user A Facebook friends into a table.
When someone logs in with Facebook I am storing, their name and Facebook id. As well as their friends, Facebook id and name.
This is how I would do it. Here is my solution if you need generated schema code let me know.
-Create three tables: registered users, buddies, lookup table
table 1: registered users
[id, userId, facebookUid]
table 2: buddies
[id, buddyid, buddy name]
table 3: You need a lookup table.
[id, userId, buddyid]
Steps:
When UserA logs in with Facebook, save their buddies into the buddies table
This approach above you don't have to worry about duplicate names. If someone updates their name, it will be changed across the board.
You can use join to find who has buddies in common.
I have two tables in my database. One is a list of members each, of course, having a different member ID. The second table is a list of items that have been designated to one member.
Please note that each table has a user_id column. Based on user_id I want only certain items displayed on their webpage.
When Joe logs to the members area, he is taken to a welcome page. On that welcome page I want Joe to be able to click on a link which will take him to a page. This page will show items that only Joe is allowed to see. If another member clicks on the link it shows a message that says something like Sorry, not for your eyes.
I really am only learning and have spent the past couple of days looking for help with this issue.
I am thinking, from what I have read, that I may just be able to amend the top of my "special page" with an if statement which would say something like
if user_id from table_members = user_id from table_items
Show all rows from table_items which = user_id
There are huge number of tutorials available on internet on displaying dynamic data. Just try doing a search on "making dynamic webpages using php" like that.
let $user_id be a variable storing userid taken from user logged into the website.
$query="select * from table_items where user_id=".$user_id ;
$result=mysql_query($result);
To fetch a row:
`$row=mysql_fetch_array($result);`
To fetch specific column from that row:
$column_data=$row[$columnNameString];
Execute that query you will only get rows whose user_id column value equals to user_id variable value.
I'm sure this is MySQL 101 and I apologise if the answer is simple, but I'm a little stuck so here I am.
I have a table of users, named 'site_members' with various fields but importantly, each with a unique id.
I also have a very simple two-field table, named 'blocked_members' which contains the id's of users who have been blocked by the logged in user, which is simply set up to store the user id of the person blocked, and the user id of the blocker:
Field 1 | Blocked
Field 2 | Blocker
Before I run a query on the 'site_members' table, I run a query on the 'blocked_members' table to find out if the current logged in user appears in either column:
$sql = "SELECT * FROM blocked_members WHERE blocker = '$loggedin_id' OR blocked = '$loggedin_id' ";
What I need to do next is get the corresponding user id from each row the logged in user's id appears in, and exclude that(those) from my main query on the 'site_members' table, but I do not know how I would go about this?
Can anyone help or point me in a cleaner direction?
You use a subselect.
SELECT * FROM whatever WHERE posting_user_id NOT IN
(SELECT blockedid FROM blocklist WHERE blockerid = <<current user viewing the page>>)
while inserting the ID of the User whose blacklist shall be applied.
You can do inner query... you cann do
... WHERE blocker NOT IN (SELECT bloker_id FROM ...)