I'm just diving into Laravel this week. I've done a few tutorials and have been able to figure out how to setup my database, loop through my records and display them in a view. With each record I am displaying a checkbox and each is set to checked="checked" based on a boolean field from the "CheckedIn column in the database. I want to be able to uncheck multiple records then submit and update that column in the database then refresh the page showing the changed records as unchecked. Just looking for a jumping off point or links to resources that explain this process better. If I could figure out how to do it via javascript and AJAX that'd be even better.
You need to post up more information for people to help you.
Your process would be something like this:
Create the table with a form, with all the checkboxes named with the ID of the row in the DB table
->
Submit the form
->
Get all the inputs for the checked boxes
->
loop through and see whether it is checked or not
->
Update that row in the database
->
Redirect back
Related
I'm using chronoforms 5, made a form for creating a record. It works all fine.
But my problem is I need a form for edit the record. I've no idea how to load & show the record data. Anyone has ideas?
You have to be able to identify the record you want to edit. Usually this is by the Record ID, the User ID, or possibly the User email if that is unique. Then you can make a copy of your entry form, rename it, and add a DB Read action at the top of the On Load event in the Setup tab - if you are using the Simple Wizard then you have to switch the form to Advanced mode in the General tab to do this.
Edit the DB Read action to link to the table and set the Conditions box to load the record you want to edit - there is a FAQ about doing that.
You should be using ChronoConnection to list the records. The user selects a record which then displays the form to edit it.
I have a jQuery datatable that has up to 1000 entries. I am displaying 5 of these entries per page but of course one could search and easily get to the record one is looking for or one could use the next button to goto the next page.
I have checkboxes attached to each of the rows in the datatable. My problem is that when I check some rows in one page and then move to another page and check other rows and then submit the form to some PHP handler, it only sends the checked rows in the last page. It does not send the ones I checked in the previous pages. How do I get these rows?
Easiest way would be to hold the "marked for deletion" attribute with the records: each time a pagination request gets fired, all "marked" rows are updated in the database according to the state of the checkbox.
Hiting the "delete all marked rows" - button then would not delete those checked records but those within the database which have the according attribute set (i.e. "marked for deletion = true")
this woul also account the fact that probably multiple user might do the same or working "against each other".
ok heres my problem.
I have a database table that i want to edit multiple rows by using one form.
I am looking for a way to be able to display a form in which i will be able to edit the rows and save the entries in a grid view kind of way.
Can this be done by dynamically letting the user choose which fields he wants to edit or provide an excel sheet kind of interface where changes are made and saved to this already existing database table.
Using PHP, if you name the form fields as nameoffield[] they will arrive in the request back to the server as an array. Just make sure empty fields have some place holder when they get sent back to the server and just parse through them one by one performing updates/inserts as necessary.
I have just started with Zend Framework, so might be a bit of a silly question coming up.
I have a Form with 5 Checkboxes. A User can click on as many checkboxes as needed. This gets entered into the Database. (1:n)
This all works fine. But now I am gotten to the part where a User can Edit the Post. The Checkbox gets shown as well as which once are active. But how do I update this now?
The Rest of the Post Update works fine, collecting the Data and send an update:
$this->getDbTable()->update($data, array('post_id = ?' => $id));
Now I want to update the Checkboxes, the 1:n Relationship. But how would I do that if I for example had 4 Checkboxes active but after the update I want only 3 active? Should I delete all entries first and than do a normal insert or is there a trick to do it?
Hope someone can help. Thanks !
Assuming that the row existing in your database is what you use to indicate that it should be checked, you will need to delete it as the update() function won't do that.
If delete / re-insert is going to be too expensive of an operation, perhaps store the checked values in the session and do an array_diff($previous_selected, $currently_selected) to get the list of items to delete.
One thing to note is that the formCheckbox view helper by default creates a hidden input with the same name as the checkbox with a value of 0.
i found it difficult,,,, fetching data from database while a buttons are randomly generated in for each how can i fetch
Without understanding what your question really is, you could go trough the mysql query result like this:
// button_text is a database column in this example
while ($row = mysql_fetch_row($result)){
echo "<button type="button">".$row['button_text']."</button>";
}
But to really help you, you need to rephrase your question!
I'll make some assumptions for what you are trying to do:
1. You have buttons that fetch more info from a db
2. The buttons are "randomly" generated, and each calls different info (pets, cars, etc).
You may or may not be using ajax, but I will describe it basically assuming straight php, and you are using a single page (for clarity in my explanation).
What you need to do is have each button either be a link or a submit for a form. This just depends on whether you want to use GET or POST. The buttons will have php generated links (if GET) or values (if POST). For example, using get the link could be "www.file.php?cat=cars". The button would just have the value of "Cars", and since bother are generated, that shouldn't be an issue keeping them the same.
When the page is now reloaded based on the click, the top of the page has a query in it to get the new info. For example, it would run a query looking for all items that have the car category. Then the new information would be displayed, and the new random buttons would show.
VERY IMPORTANT: Sanitize all GET and POST values before using them in a query