I was wondering how to generate information based on what checkbox a user has clicked. I have a from with php code that picks up information from a database and displays it as a check button. I would like to have a system form example the users checks a radio button on what movies they have watched before and once the click submit the system then displays a movie that it thinks they might like to watch based on what they have already watched. I started doing this by saying if the summit button is clicked and the users clicked the first to checkboxes and it would run a query and pick a movie from the database from an id. Is there a better way to do this as this takes a lot of time and only works if the users checks two checkboxes.
Are you saying at the end that you made the system work? I have to guess a bit at what you are trying to say due to the grammar issues. Do you want it to work if the user clicks two radio buttons, or work in a different way?
I want it to work now matter how many check boxes are clicked and out only works for the first two radio buttons and even if the page is refreshed and the users clicks on check boxes there and four it brings up the result for the first two.
We can’t help you without seeing the code used. Looks like you are using a mixture of radio buttons and checkboxes. That’s hard to see.
Does the code work at present with 2 radio buttons?
sorry the system only uses checkboxes, got radio buttons and checkboxes mixed up
Still need to see the code in order to suggest why it might not work as you expect it to.
One thing that you need to keep in mind with checkboxes is that if a checkbox isn’t checked then nothing will be sent to the server so there’ll be no entry in the $_POST array for that checkbox.
Adding to this, you must check to make sure that field is present in the $_POST
array. Otherwise, you will receive an undefined index error in a later line when trying to reference it.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.