and I want to display the data in a page of a particular user based on there ID, that is one needs to enter his/her to display his/her data from database. can anyone explain me how can I do it???
import wixData from 'wix-data';
let userId = < id of user >
wixData.query("attendance")
.eq("_id", userId)
.find()
.then( (results) => {
if(results.items.length > 0) {
let items = results.items;
let item = items[0];
$w("#name").text = item.name;
$w("#sub1").text = item.sub1;
... set all of your other fields ...
} else {
// handle case where no matching items found
}
} )
.catch( (error) => {
let errorMsg = error.message;
let code = error.code;
} );
You might want to set up a table of all of the users, and then when you click on a user it goes to a dynamic page displaying all of their information. Use the Table Index example to see how that's done.
We are unable to provide full code solutions. You can take advantage of the Wix Code Resources including a good number of examples which demonstrate many of the techniques that you need to accomplish your goal. Here are the locations of the examples:
The code snippet that I posted above shows exactly how to perform a query based on the a user ID. You can get the user ID from an input field on the screen:
let userId =$w("#input").value;
Once you have the userId, you can then perform the query to get the user's data.
Wishlist Page is the new official platform for requesting new features. You can vote, comment, and track the status of the requested features (requests from this page will be migrated to the new Wishlist soon).
You can do a query like this:
import wixData from 'wix-data'; let userId = < id of user > wixData.query("attendance") .eq("_id", userId) .find() .then( (results) => { if(results.items.length > 0) { let items = results.items; let item = items[0]; $w("#name").text = item.name; $w("#sub1").text = item.sub1; ... set all of your other fields ... } else { // handle case where no matching items found } } ) .catch( (error) => { let errorMsg = error.message; let code = error.code; } );
You might want to set up a table of all of the users, and then when you click on a user it goes to a dynamic page displaying all of their information. Use the Table Index example to see how that's done.
@Jeff Haskins It's not possible to add a filter from the dataset's Settings window, but you should be able to filter by ID (_id) in code.
Thanks a lot @Yisrael I have learned a java script a bit and then did what you told me to do thanks a lot!
Thanks for replying, may god bless you! I want to discuss this thing with you in deep! Can I you tell me where should I contact you?
Contact is in the forum. This way other users can learn and even contribute their experiences.
I would suggest playing with the Table Index example. You can then start building your own site that retrieves user information.
@Yisrael (Wix) I am not good at coding! but I need a online attendance system! can you please explain me how to do it
This what error I am getting please help me out
No, I know about basic coding! I just can't figure out this part. Can you please help me to figure it out please
We are unable to provide full code solutions. You can take advantage of the Wix Code Resources including a good number of examples which demonstrate many of the techniques that you need to accomplish your goal. Here are the locations of the examples:
https://support.wix.com/en/article/wix-code-index-of-examples
https://www.wix.com/code/home/examples
https://www.grampsworkbench.com/examples
The code snippet that I posted above shows exactly how to perform a query based on the a user ID. You can get the user ID from an input field on the screen:
let userId = $w("#input").value;
Once you have the userId, you can then perform the query to get the user's data.
Good luck
Is your problem solved?