Checkbox Check to specify the field you want to update - php

Can you please enlighten me and give some ideas!
I can view my data from the database and insert a data into my DB.
Now all i want is to have a checkbox in each field, if i SELECT all my data and view it in a table, I will choose or check the field that i want to edit or to delete and click the button to pass the selected field into my edit form..
So how can i pass the value of the checkbox to the edit button?

When you post data to server if check box is clicked then value of check box is posted to server and you can find it in post data by its name, for e.g.
<input type="checkbox" value="1" name="chkEmail" />
in php you can get it this way
$_POST['chkEmail']
so on server side you can solve your problem like this
if(isset($_POST['chkEmail']))
updateEmail();
and do this for your every property, you can update each column with single query, or you can build query for update.

Related

How to post the value in text box the were generate using looping from database

I have a table that were listed using looping from mysql database. In column edit i had a textbox and edit button. I want to post the value of the text box when user click edit button.My problem is when i click the edit button the value in the post take the value of last one(which group name = QW).
when i click the edit button the value in the post take the value of last one(which group name = QW).
So give them unique names.
Probably ones which incorporate the row number in the database.
e.g.
name="foo[row_number]"
… which will then let you loop over $_POST['foo'] as an associative array.

Getting values of all checked checkboxes in PHP and put them in an array

I'm creating a CMS in which I have an overview of pages. I want the user to be able to mass delete these pages and so I have created a form in which each page has a checkbox with the pages database ID as value and name:
<input class="mass-delete-check" type="checkbox" name="<?=$page["id"]?>" value="<?=$page["id"]?>" id="<?=$page["id"]?>">
Now when I submit this form I need to get the values of the checkboxes that are actually checked and put them in an array I can go through to delete them. The thing here is that I will have to get checkbox values based on if they are checked and not on their name because I can't know all names.
Does anyone have a solution to this?
Use the same name for all checkboxes. So after submiting you will have array with page IDs to delete.
<input class="mass-delete-check" type="checkbox" name="delete_pages[]" value="<?=$page["id"]?>" id="<?=$page["id"]?>">
After submit you would get array of IDs with $_POST['delete_pages'], which contains actual page IDs what you need to delete.

php - Get radio button name attributes value

Sorry if this is a stupid question but im really not sure how to tackle this, perhaps im overthinking. I need to retrieve both the name attributes value and the value attributes value. Have a look at img below:
echo'<input type="radio" name="'.$eventId[].'" value="'.$team1.'">';
The name contains the event_id and the value contains user selection. I need the name Ids value to insert event Id into db along with user selection.
I know how to retrieve the rad value attribute but not sure about the name, maybe Im overthinking it or need to change my logic. Any ideas?
If user select Australia radio button than in PHP you will get value 'Australia' but you want the value 'Australia_80' to store in db. Change all your radio button values and names like
<input type="radio" value="Australia_80" name="getRadio">
<input type="radio" value="Canada_81" name="getRadio">

check data and retrieve value from database in php in click in textbox

i have a database with these field
member id(mid),sponsor id(sid) ,sponsor name(sname)
and a joining form like as
now i want to add this feature when i type a sponsor id then its tell me this id is available in database or not ...and if not available then it show message front of this field and if yes , then when i click in sponsor name field its automatically fill the name of sponser of this id ..and i want all this happened before click submit button..thanks..
Please use the JQuery validate plugin for this. Below is the example that how to use remote function in this plugin.
http://docs.jquery.com/Plugins/Validation/Methods/remote

How to get the textbox value when its corresponding checkboxes are ticked?

When a user ticks a checkbox and enters data into the corresponding textbox and submits, I want to show a form which will display the textbox values which checkboxes were ticked
Have you considered trying a tutorial and seeing how that works?
http://www.homeandlearn.co.uk/php/php4p11.html

Categories