Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm currently working on a website which allows the costumer to personally add movies to a database. So I wrote a PHP class which initially loads all the data needed from a database and creating a table which kind of looks like this:
How do I theoretically proceed to make those buttons work(Which, as they change things in a database should "execute" php-functions).
theoretically this is how you should proceed:
First the database piece
you will create 4 fields
each field corresponding to the table header (notice there should be no space in the name of the field) -- movie_id will be numerical, name will be varchar, etc.
Next the code
I take it the second row are all inside tag? if not make it so
Make sure the form method is POST
I recommend making the action of the form go to another page (keeps it clean)
user clicks on "save changes" button
On the other page (specified in form action), you will receive the data in your $_POST var; based on each input's name, this will be accessible in post. So for example, if your input name for "name" field is "movie_name" then this data will be in: $_POST['movie_name']
Store each field's POST data in a variable... i.e. $movieName = $_POST['movie_name'] ---- THIS IS JUST AN EXAMPLE! YOU SHOULD NEVER ACCESS POST DATA DIRECTLY!! YOU MUST SANITIZE/VALIDATE ETC. THIS DATA BEFORE STORING IN DATABASE
Assuming you have a database link already established, simply insert the data into the table you created earlier
Hope this helps you get started!
Best,
-Rush
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I was just wondering how do I make my website preview some info after the user searches for something stored in the database.
Basic approach for previewing user names as you type in a search bar. For this to work, you will need to use AJAX to query the server and also display the result as a preview for the user to click on if they want, without having to refresh the page.
User types 'Joe' into the search bar
The onChange() even is fired and you query your server with that the user has written "Joe". Keep in mind this query is via AJAX, so as not to force the page to reload.
Server side, you do a MySQL lookup of the table users, where the name is something like "Joe". SELECT NAME FROM USERS WHERE NAME LIKE '%what_you_sent_on_AJAX_request%' LIMIT 10;
The browser receives the response from the AJAX request and displays a nice dropdown with the output of the server. When the user actually click son this "previews" it is in that moment that you would actually reload to the page or take the user to a new page based on what they have clicked on.
That's a very basic approach for it.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm currently creating a website with a list of members on a page.
Members will register via a form, and once the form is filled in, I would like a card component to be created on another page (which will be password protected and only usable by an admin) with the choice to either accept the members request (of which their name will be automatically added to the members page) or decline the request, in which case the card will be deleted.
Can anyone suggest how I might go about automatically creating a card including information via the form?
Thanks in advance.
Your question is very general.
The easiest way is to use php to control the data of your form and with mysql PDO to insert them into a database.
Then in the database add a column for each registered "status", that when it is at 1, you post it as a confirmed member. If it is at 0 it must be confirmed.
I hope I've helped you
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am using php for my application and i have 180 vendors registered on my app,each vendor has a unique id which is stored in database.I have to implement a counter that each time a user clicks on a view details button of a particular vendor the counter of that particular vendor is incremented and is shown on the vendor portal of that vendor . I don't have an exact idea how to approach this problem so I can show that how many times the user has clicked the view details button of that particular vendor.Can anyone guide me ?
Since you are using php there is no hard and fast rule to update counter on database. You should create a method that update counter on your database and use ajax to call that function using javascript or when user clicks on view detail then I think the page loads from new url. If this is the case then before rendering the page you should include call a function to increment the counter associated with the vendor in your database.
Create a table in the DB with vendor id and a counter. Each time a user clicks on a view details button of a particular vendor increment the counter, i.e update the counter in the DB using ajax call. Hope you are familiar to call a ajax function and update the DB.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am an electronic engineering student. I have a doubt concerning Web development. I have to make a web site for doctors to enter patients data. Most of the data are in check box format. My question is regarding saving and re fetching check box status from the data base, so that the user can see what all are checked previously and what all are not checked when he log's in back the next time.
And also how can i replace the check-box status in database if i change the status. I searched about this in internet but there is no much data concerning this. So if anyone could guide me or give me a link or example codes where i can look and study, it will be a great help for me.
You can save the values of a particular check box in many different way and there are tons of resources online for this, I am sure you have come accross this information before.
You could save your check box values as a string with a string delimiter, for example: A-B-C-D-E. This was you can split/explode the string whenever you need to retrieve the values again as an array and appropriately mark the corresponding check boxes once they sign in again.
Some Resources: http://www.html-form-guide.com/php-form/php-form-checkbox.html
send checkbox value in PHP form
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
When there is a list of modifiable records that I want to show to users, usually I would name the id of each div as the record id of the database table. So that when a user click on a button on the list to perform certain action (eg. delete, modify etc.), by jQuery I can get the id of it by selecting the closest id in the div, and then I can know which record the user is selecting. Is it a good way to do so? What are your methods of doing this?
You can name the ID whatever you wish, and it would be useful to have a record of the ID, but I'd go with this data attribute solution:
<div data-id="14"></div>
That way, you don't have to name your ID something like id_14 (this is because ID and class names must start with a letter).
To retrieve that in jQuery, simply do $('div').data('id');.
It is a good way to do it.
You could also use data attributes if you wish. Just make sure that those ids are unique for the whole page.
If you are going to show one user in more than one part of the page, then I would recommend you to use data attributes in order code properly and validate correctly.