Number of dropdowns based on selection of first dropdown - php

Programming in Bootstrap and PHP I am trying to create a dynamic form which has the following.
User uses a dropdown to select number from 1 to 10.
The page then displays x number of dropdowns.
Each dropdown is the same and displays a list of userID from a MySQL table tblUsers
Once the user makes a selection from each dropdown, it then shows a second dropdown immediately underneath showing a list of videos from a second MySQL table tblVideos. Meaning that the second dropdown is based on the results from the first.
Once all dropdowns have been selected. Submit is pressed and the results are sent as an array to the table tblVideoStored
Any ideas how the PHP and MySQL would be in a simple form..

Based on what you plan to achieve, you may want to look into combining php with ajax (Javascipt). Below are some examples that should set you on the right path
https://www.sitepoint.com/community/t/using-ajax-to-populate-dropdown-menu/4350/2
http://blog.chapagain.com.np/using-jquery-ajax-populate-selection-list/

Related

Add or Remove Dynamic Dependent Select Box data from two mysql tables using jQuery with PHP Ajax

I need complete sample code to Add or Remove Dynamic Dependent Select Box data from two mysql tables using jQuery with PHP Ajax
Dependent select data should be come these below tables. And should be add and remove button to add row.
Category
Sub Category
Below is sample data, but in this, dependent select data coming from only one mysql table.
https://www.webslesson.info/2019/09/add-or-remove-dynamic-dependent-select-box-using-jquery-with-php-ajax.html
Can any provide me sample demo with source code ?
Please this sample image
Please see this image, There are three tables, (1) Items, (2) Category, (3) Sub Category, I need same like this, but data should come from Category table and sub category table in dependent select boxes. And this is multi dynamic row. Can you give me all demo code, becuase I do not know about Jave,Ajax and jQuery.
Below is sample demo and source code weblink, But in this sample, He is getting data from only one table for both dependent boxes category and sub category. Data should be come from two tables both dependent boxes.
enter link description here
I hope you understand what I required.

populating dropdownlist based on the condition when you click on add button in phpgrid

I am using phpgrid in my project and i wanted to see a dropdownlist to be populated based on the condition.
When i click on the add buttoon in phpgrid, it will allow me to select the Country and based on the country selected, the dropdownlist to be generated which belonging to the selected country.
In my MySQL database i have a location tables separated with parent and child columns and i can able to see the proper result in mysql views. The same thing i wanted to implement with phpgrid.
Ref: http://phpgrid.com/
Have you read http://phpgrid.com/example/nested-dropdown/ ? Seems what you are looking for.

PHP selection in dropdown list

I need to create 4 dropdown list where the options are the names of the candidates (ex. 5 candidates) in a certain position (ex.Representatives). When i select a candidate from the list in the first dropdown, there will be 4 options in the second dropdown, and in the third dropdown there will be 3 options and so on. To sum it up, what is the php code for removing the list in the next dropdown upon selection without submitting it yet.
Use jQuery......jQuery help you to do validations easily. So it may take less time for client side validation
For e.g.;
$("#id_of_dropdown").change(function () {
// Some Code Here like you want to change another dropdown put if else here
});

fill textbox with values based on selected table cell value (ajax call & mysql)

I have a table which is populated by values obtained from mysql database. I want to use an ajax call function so that when I click a cell - based on the cell value the textboxes get filled. Now the data in the textboxes will be from another table in the mysql database.
So an example of how it would work is:
I have one table for credentials, which shows user name and their user id.
On the website this is shown as a table. Now when i click the a cell which has a user name. The textbox would be populated by the users say total exams taken which is obtained from exams table in the mysql.
I am totally stumped on how to go about doing this. Please can someone help!
You can do this by using ajax .
use this
$("#cell").click(function(){
$.get("file.php?id="+$(this).val(),function(data){
$("#textboxid").val(data);
})
})
the file.php is the file which will perform the back-hand calling to database and make a output.

Displaying dynamic text based on drop down box selection

I am using Dreamweaver to create a site.
I have created my database within phpMyAdmin and have two tables set up that contain the data I wish to display on my site. (it is a football team site and the page I am editing displays player profiles).
I have set up a drop down box, which is connected to my players table in phpMyAdmin. This I have set to display surname of the player. (I've set up the recordset to retrieve all data from my "players" table)
Below that, I have another div which contains text that I want to display based on the selection on the drop down list. For example, Position, appearances, goals, assists, etc.
Position: Dynamic text to be displayed here
Appearances: Dynamic text to be displayed here
etc
(This data would come from the "players_info" table - but the two tables are connected via the player_id field which is contained in both)
What I can't seem to do is work out how to get the text to update when the user would select a player from the drop down list.
Any help would be greatly appreciated.
Thanks
James
You can do these using ajax function.
when you select a player name ,then javascript or jquery event will be called which include a php file.
This php file must contain the sql which fetch your desired player information.
when server give response, then display it your corresponding div

Categories