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 6 years ago.
Improve this question
On a php page I will show the records of table. Then I want to delete the selected rows by checkboxes by clicking the button. How do I do that?
You can simply make with POST method also
Just set the id of row (retreive from database) as value of checkbox.
<input type="checkbox" name="chk[]" value=<?php echo $id;?> " >
and then hit the DELETE button.
On POST page you will get the ID of checked record.
Get all ID and combine all ID with implode function
$chkIds = $_POST["chk"];
$allIds = implode("','",$chkIds);
run the SQL query like :-
"DELETE FROM tablename WHERE id IN ('$allIds')"
you should pass your selected data id to your server;
FE: ajax -> send data to SERVER:php -> DATABAST:mysql run sql delete from table where xxx
So you should try learn about ajax and php pdo
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 1 year ago.
Improve this question
My plan is to automatically create checkboxes with names and random values for example a hundred in a for loop. Is there any way to do this?
And if i want to use these how to change the value and save it to the array?
in php
<?php
for($i=0;$i<100;$i++){
echo '<input type="checkbox">';
}
//if you want to add a submit btn at last
echo '<input type="submit" value="Submit">';
?>
It is the code to automatically create 100 checkboxes
And put your own values and styles
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 using on WordPress an amazing tablepress plugin and I have a table on one page that I want to read and pass the value of the table to an input form.
The table is the result of a search and will be always a row and a column, just one number.
There is any way to do that with PHP or javascript?
Or any other way?
I will share some code of the result in the page...
Thanks in advance!
<table id="tablepress-1" class="tablepress tablepress-id-1">
<tbody>
<tr class="row-1">
<td class="column-1">319</td>
</tr>
</tbody>
</table>
You probably have jquery available...if so:
var fromTable = $("#tablepress-1 tr td").text() will give you the value you want.
You can do something similar to put it into your form:
$("#myInputField").text(fromTable)
And if you don't have jQuery, but you KNOW the tables you can get the value like this:
var fromTable = document.getElementById("tablepress-1").rows[0].cells[0].innerText
(Consider all of this pseudo-code and fix it up to suit your situation. The debugger is your friend!)
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 trying to build a chatbox for my friends to use and before a friend can join the room I want them to click on a bottom which has a default value of JoinChat. AND when they click that I want to send request to the database using ajax to allow them enter the room and then change the value of the bottom to LeaveChat
Assuming they have entered the room and they wan to leave the room so when they click on the same bottom, send another request to database to disconnect them from the chat room.
<input type="button" value="JoinChat" onClick="" id="btn">
Here is quick solution:
var isConnected = false;
var NOTCONNECTEDTEXT = 'JoinChat'
var CONNECTEDTEXT = 'LeaveChat'
function btnClick(event){
isConnected = !isConnected
document.querySelector('#btn').value =
isConnected ? CONNECTEDTEXT : NOTCONNECTEDTEXT
}
<input type="button" value="JoinChat" onClick="btnClick()" id="btn">
Just implement what you need, but the code is bad, to improve the code, recommend you use library like React.
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 8 years ago.
Improve this question
I have a simple HTML where you can click images. These images, whence clicked will moved to the Top Nav bar, I have IDs from this images and able to get each of them using jquery/javascript. I have this IDs set to an array variable.
My questions, is there a way to pass this to the Form then I issue a Submit so I can process the arrays. It is a 1D array with just IDs.
You can use hidden inputs:
<input type="hidden" name="image_ids[]" value="1">
<input type="hidden" name="image_ids[]" value="2">
<input type="hidden" name="image_ids[]" value="3">
Just create a new hidden input for each image id, with the same name image_ids[].
Note that when you append [] to the name of various input fields, these values are submitted as an array, in this case named image_ids.
Another solution is just to concatenate all the IDs with a comma: "1,2,3,4,5" and send it in just one hidden input field (instead of a bunch of hidden input fields), then in your server script (assuming you're using PHP) you can convert the string "1,2,3,4,5" to an array using something like: $image_ids = explode(',', $_POST['image_ids']);.
Good look.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I need to add in all the textbox manually in my project.
<form>
<?php for($i=0;$i<3;$i++){ ?>
<input type="text" name="product[]">
<?php } ?>
</form>
how can i solve this problem so that the number of product for insert can be flexible.
For example, user1 need to purchase 4 item, user2 wan to purchase 8 item. wihtout dynamic textbox, i need to add the textbox manually by adjusting the looping value (in my coding).
It sounds like this is an update to customer products right?
if so, you probably have products array somewhere.
so you might do :
$products = $customer->products ;//or your array
for($i=0;$i<count($products);$i++){
// your code
}
or you can add it via javascript (sounds more like it if this is the purchase moment - new products, not update)
or you might want to have somewhere a config per customer.
or Please be more specific and more descriptive