₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,347,659 members, 8,528,718 topics. Date: Wednesday, 02 December 2026 at 06:43 PM

Toggle theme

Need Help With Php And Mysql - Programming - Nairaland

Nairaland Forum › Science/Technology › Programming › Need Help With Php And Mysql (1020 Views)

1 Reply (Go Down)

Need Help With Php And Mysql by marvzkiddx(op): 8:06am On May 13, 2019
Okay....
I have a user table named marv_users
Each user in the table has an ID
Now i want to initiate a row in the table named Anonymous
The anonymous is has a value of 0 and 1
0=Off
1=On

The table and the row has been added with 0 as a default value.

Now,i want to add a checkbox on the website for each logged in user

Checkbox with a label
Post as Anonymous?

When checkbox is clicked,value in Table marv_users,row Anonymous changes to 1 and when unclicked changes back to the default value 0.


How do i do it for each user with different ID's....


Secondly,
If that is working already, how do i pass it to the website...

Like i want to use it in a comments section

It's a php IF function....

How do i add it??

Please am i clear enough.??

Please help
Re: Need Help With Php And Mysql by resosdigital(m): 8:13am On May 13, 2019
From the top of my head here is how I would do it.

First authenticate the user to determine the user id.

When the checkbox in the comment section is clicked make an ajax post request and update the row.

Rather than trying to retrieve again from the database I will use js to store the state of the checkbox and use that in the frontend.
Re: Need Help With Php And Mysql by Nobody: 10:47am On May 13, 2019
marvzkiddx:
Okay....
I have a user table named marv_users
Each user in the table has an ID
Now i want to initiate a row in the table named Anonymous
The anonymous is has a value of 0 and 1
0=Off
1=On

The table and the row has been added with 0 as a default value.

Now,i want to add a checkbox on the website for each logged in user

Checkbox with a label
Post as Anonymous?

When checkbox is clicked,value in Table marv_users,row Anonymous changes to 1 and when unclicked changes back to the default value 0.


How do i do it for each user with different ID's....


Secondly,
If that is working already, how do i pass it to the website...

Like i want to use it in a comments section

It's a php IF function....

How do i add it??

Please am i clear enough.??

Please help
Contact me on 0-8-1-3-8-6-6-3-6-9-7 so it can be sorted out
Re: Need Help With Php And Mysql by marvzkiddx(op): 10:58am On May 13, 2019
miccolo2:
Contact me on 0-8-1-3-8-6-6-3-6-9-7 so it can be sorted out
Thanks man....
Re: Need Help With Php And Mysql by marvzkiddx(op): 10:59am On May 13, 2019
resosdigital:
From the top of my head here is how I would do it.

First authenticate the user to determine the user id.

When the checkbox in the comment section is clicked make an ajax post request and update the row.

Rather than trying to retrieve again from the database I will use js to store the state of the checkbox and use that in the frontend.
Thanks boss
Re: Need Help With Php And Mysql by makavele: 12:49pm On May 13, 2019
marvzkiddx:
...
If I get you correctly, you want people to be able to comment as anonymous users (hence, no name, or email or personal data shown)

A more efficient way to is to have an "Anonymoust Post?" tag for each post that will store as Yes or No in the db.

For the logic, you can just check to see if user has clicked the checkbox to "post as anonymous".

If yes, then replace username, name, email or any private data with e.g. Anonymous User , empty string, default predefined strings, etc; based on your customization.

Then when this post is sent to the db for storage, you can tag the Anonymoust Post? as "Yes" or "No" depending on if it was or not.
Re: Need Help With Php And Mysql by BOLAJIAJANI(m): 8:36am On May 14, 2019
Well, if I get you very well, you want registered users to be able to post certain things as anonymous? If yes, then what you have there is not exactly complete.
1 Reply

Just Created A News Website With Php And Html • I Built A Lpg Gas Station Sales Software Script With Php. • What I Created With Php And Mysql • 2 • 3 • 4

Pay And Learn Programming • The Leading Tech Hub Center In Umuahia • I Need Developers