Get values from other table columns, if row is checked
up vote
-2
down vote
favorite
I am new in programming and need some help. Any idea or solution will help me a lot
I have table organized
<?php
if (isset($_POST['submit'])) {
$id = $_POST['id'];
$quantity = $_POST['quantity'];
$color = $_POST['color'];
var_dump($id); // i get correct value
var_dump($quantity); // I dont get correct, I get always same values no matter if they are checked or not
var_dump($color);/ I dont get correct, I get always same values no matter if they are checked or not
// For ex, if I check only Audi, $id = 1, $quantity() - will be data from all rows and same for $color
}
?>
<form id="form" name="" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" >
<table class="table table-bordered" id="example2">
<thead>
<tr class="success">
<th>#</th>
<th>Name</th>
<th>Quantity</th>
<th>Code</th>
<th>Option</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" class="form-control" name="id" value="1"></td>
<td>Audi</td>
<td><input type="text" name="quantity">120</td>
<td>123456</td>
<td>
<select name="color" name="color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Silver</option>
</select>
</td>
</tr>
<tr>
<td><input type="checkbox" class="form-control" name="id" value="2"></td>
<td>Mercedes</td>
<td><input type="text" name="quantity">200</td>
<td>112233</td>
<td>
<select name="color" name="color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Silver</option>
</select>
</td>
</tr>
<tr>
<td><input type="checkbox" class="form-control" name="id" value="3"></td>
<td>Kia</td>
<td><input type="text" name="quantity">50</td>
<td>879</td>
<td>
<select name="color" name="color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Silver</option>
</select>
</td>
</tr>
<tr>
<td><input type="checkbox" class="form-control" name="id" value="4"></td>
<td>Ford</td>
<td><input type="text" name="quantity">120</td>
<td>987</td>
<td>
<select name="color" name="color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Silver</option>
</select>
</td>
</tr>
</tbody>
</table>
</table>
<button type="submit" name="submit">Submit</button>
</form>
I am having trouble in getting correct data for checked row. In comments where php code is written I am having trouble in finding out how to do it correctly.
Once data is submitted to for, I need to get an array which holds data from checked row. If 5 rows are selected, I need to get 5 arrays.
php
|
show 1 more comment
up vote
-2
down vote
favorite
I am new in programming and need some help. Any idea or solution will help me a lot
I have table organized
<?php
if (isset($_POST['submit'])) {
$id = $_POST['id'];
$quantity = $_POST['quantity'];
$color = $_POST['color'];
var_dump($id); // i get correct value
var_dump($quantity); // I dont get correct, I get always same values no matter if they are checked or not
var_dump($color);/ I dont get correct, I get always same values no matter if they are checked or not
// For ex, if I check only Audi, $id = 1, $quantity() - will be data from all rows and same for $color
}
?>
<form id="form" name="" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" >
<table class="table table-bordered" id="example2">
<thead>
<tr class="success">
<th>#</th>
<th>Name</th>
<th>Quantity</th>
<th>Code</th>
<th>Option</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" class="form-control" name="id" value="1"></td>
<td>Audi</td>
<td><input type="text" name="quantity">120</td>
<td>123456</td>
<td>
<select name="color" name="color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Silver</option>
</select>
</td>
</tr>
<tr>
<td><input type="checkbox" class="form-control" name="id" value="2"></td>
<td>Mercedes</td>
<td><input type="text" name="quantity">200</td>
<td>112233</td>
<td>
<select name="color" name="color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Silver</option>
</select>
</td>
</tr>
<tr>
<td><input type="checkbox" class="form-control" name="id" value="3"></td>
<td>Kia</td>
<td><input type="text" name="quantity">50</td>
<td>879</td>
<td>
<select name="color" name="color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Silver</option>
</select>
</td>
</tr>
<tr>
<td><input type="checkbox" class="form-control" name="id" value="4"></td>
<td>Ford</td>
<td><input type="text" name="quantity">120</td>
<td>987</td>
<td>
<select name="color" name="color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Silver</option>
</select>
</td>
</tr>
</tbody>
</table>
</table>
<button type="submit" name="submit">Submit</button>
</form>
I am having trouble in getting correct data for checked row. In comments where php code is written I am having trouble in finding out how to do it correctly.
Once data is submitted to for, I need to get an array which holds data from checked row. If 5 rows are selected, I need to get 5 arrays.
php
2
Even if you are new to programming: what have you tried on your own? Where exactly are you stuck?
– Nico Haase
Nov 20 at 8:27
1
I'm voting to close this question as off-topic because even the OP admits it's not the correct way to ask questions.
– Ken Y-N
Nov 20 at 8:28
1
@T.J.Crowder I prefer to be done in PhP
– Mahmut
Nov 20 at 8:43
Your best bet here is to do your research, search for related topics on SO, and give it a go. If you get stuck and can't get unstuck after doing more research and searching, post a Minimal, Complete, and Verifiable example of your attempt and say specifically where you're stuck. People will be glad to help. But for instance, for PHP to even get the fields above, you're going to need aform
and a means of submitting it. PHP also uses a specific naming convention for repeated fields, etc. Any decent PHP form tutorial should cover these basics.
– T.J. Crowder
Nov 20 at 8:47
1
@T.J.Crowder I made changes to my code, on the beginning you can PhP code, that is the part of where I get stacked.
– Mahmut
Nov 20 at 9:06
|
show 1 more comment
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
I am new in programming and need some help. Any idea or solution will help me a lot
I have table organized
<?php
if (isset($_POST['submit'])) {
$id = $_POST['id'];
$quantity = $_POST['quantity'];
$color = $_POST['color'];
var_dump($id); // i get correct value
var_dump($quantity); // I dont get correct, I get always same values no matter if they are checked or not
var_dump($color);/ I dont get correct, I get always same values no matter if they are checked or not
// For ex, if I check only Audi, $id = 1, $quantity() - will be data from all rows and same for $color
}
?>
<form id="form" name="" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" >
<table class="table table-bordered" id="example2">
<thead>
<tr class="success">
<th>#</th>
<th>Name</th>
<th>Quantity</th>
<th>Code</th>
<th>Option</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" class="form-control" name="id" value="1"></td>
<td>Audi</td>
<td><input type="text" name="quantity">120</td>
<td>123456</td>
<td>
<select name="color" name="color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Silver</option>
</select>
</td>
</tr>
<tr>
<td><input type="checkbox" class="form-control" name="id" value="2"></td>
<td>Mercedes</td>
<td><input type="text" name="quantity">200</td>
<td>112233</td>
<td>
<select name="color" name="color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Silver</option>
</select>
</td>
</tr>
<tr>
<td><input type="checkbox" class="form-control" name="id" value="3"></td>
<td>Kia</td>
<td><input type="text" name="quantity">50</td>
<td>879</td>
<td>
<select name="color" name="color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Silver</option>
</select>
</td>
</tr>
<tr>
<td><input type="checkbox" class="form-control" name="id" value="4"></td>
<td>Ford</td>
<td><input type="text" name="quantity">120</td>
<td>987</td>
<td>
<select name="color" name="color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Silver</option>
</select>
</td>
</tr>
</tbody>
</table>
</table>
<button type="submit" name="submit">Submit</button>
</form>
I am having trouble in getting correct data for checked row. In comments where php code is written I am having trouble in finding out how to do it correctly.
Once data is submitted to for, I need to get an array which holds data from checked row. If 5 rows are selected, I need to get 5 arrays.
php
I am new in programming and need some help. Any idea or solution will help me a lot
I have table organized
<?php
if (isset($_POST['submit'])) {
$id = $_POST['id'];
$quantity = $_POST['quantity'];
$color = $_POST['color'];
var_dump($id); // i get correct value
var_dump($quantity); // I dont get correct, I get always same values no matter if they are checked or not
var_dump($color);/ I dont get correct, I get always same values no matter if they are checked or not
// For ex, if I check only Audi, $id = 1, $quantity() - will be data from all rows and same for $color
}
?>
<form id="form" name="" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" >
<table class="table table-bordered" id="example2">
<thead>
<tr class="success">
<th>#</th>
<th>Name</th>
<th>Quantity</th>
<th>Code</th>
<th>Option</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" class="form-control" name="id" value="1"></td>
<td>Audi</td>
<td><input type="text" name="quantity">120</td>
<td>123456</td>
<td>
<select name="color" name="color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Silver</option>
</select>
</td>
</tr>
<tr>
<td><input type="checkbox" class="form-control" name="id" value="2"></td>
<td>Mercedes</td>
<td><input type="text" name="quantity">200</td>
<td>112233</td>
<td>
<select name="color" name="color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Silver</option>
</select>
</td>
</tr>
<tr>
<td><input type="checkbox" class="form-control" name="id" value="3"></td>
<td>Kia</td>
<td><input type="text" name="quantity">50</td>
<td>879</td>
<td>
<select name="color" name="color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Silver</option>
</select>
</td>
</tr>
<tr>
<td><input type="checkbox" class="form-control" name="id" value="4"></td>
<td>Ford</td>
<td><input type="text" name="quantity">120</td>
<td>987</td>
<td>
<select name="color" name="color">
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Silver</option>
</select>
</td>
</tr>
</tbody>
</table>
</table>
<button type="submit" name="submit">Submit</button>
</form>
I am having trouble in getting correct data for checked row. In comments where php code is written I am having trouble in finding out how to do it correctly.
Once data is submitted to for, I need to get an array which holds data from checked row. If 5 rows are selected, I need to get 5 arrays.
php
php
edited Nov 20 at 9:10
asked Nov 20 at 8:26
Mahmut
41
41
2
Even if you are new to programming: what have you tried on your own? Where exactly are you stuck?
– Nico Haase
Nov 20 at 8:27
1
I'm voting to close this question as off-topic because even the OP admits it's not the correct way to ask questions.
– Ken Y-N
Nov 20 at 8:28
1
@T.J.Crowder I prefer to be done in PhP
– Mahmut
Nov 20 at 8:43
Your best bet here is to do your research, search for related topics on SO, and give it a go. If you get stuck and can't get unstuck after doing more research and searching, post a Minimal, Complete, and Verifiable example of your attempt and say specifically where you're stuck. People will be glad to help. But for instance, for PHP to even get the fields above, you're going to need aform
and a means of submitting it. PHP also uses a specific naming convention for repeated fields, etc. Any decent PHP form tutorial should cover these basics.
– T.J. Crowder
Nov 20 at 8:47
1
@T.J.Crowder I made changes to my code, on the beginning you can PhP code, that is the part of where I get stacked.
– Mahmut
Nov 20 at 9:06
|
show 1 more comment
2
Even if you are new to programming: what have you tried on your own? Where exactly are you stuck?
– Nico Haase
Nov 20 at 8:27
1
I'm voting to close this question as off-topic because even the OP admits it's not the correct way to ask questions.
– Ken Y-N
Nov 20 at 8:28
1
@T.J.Crowder I prefer to be done in PhP
– Mahmut
Nov 20 at 8:43
Your best bet here is to do your research, search for related topics on SO, and give it a go. If you get stuck and can't get unstuck after doing more research and searching, post a Minimal, Complete, and Verifiable example of your attempt and say specifically where you're stuck. People will be glad to help. But for instance, for PHP to even get the fields above, you're going to need aform
and a means of submitting it. PHP also uses a specific naming convention for repeated fields, etc. Any decent PHP form tutorial should cover these basics.
– T.J. Crowder
Nov 20 at 8:47
1
@T.J.Crowder I made changes to my code, on the beginning you can PhP code, that is the part of where I get stacked.
– Mahmut
Nov 20 at 9:06
2
2
Even if you are new to programming: what have you tried on your own? Where exactly are you stuck?
– Nico Haase
Nov 20 at 8:27
Even if you are new to programming: what have you tried on your own? Where exactly are you stuck?
– Nico Haase
Nov 20 at 8:27
1
1
I'm voting to close this question as off-topic because even the OP admits it's not the correct way to ask questions.
– Ken Y-N
Nov 20 at 8:28
I'm voting to close this question as off-topic because even the OP admits it's not the correct way to ask questions.
– Ken Y-N
Nov 20 at 8:28
1
1
@T.J.Crowder I prefer to be done in PhP
– Mahmut
Nov 20 at 8:43
@T.J.Crowder I prefer to be done in PhP
– Mahmut
Nov 20 at 8:43
Your best bet here is to do your research, search for related topics on SO, and give it a go. If you get stuck and can't get unstuck after doing more research and searching, post a Minimal, Complete, and Verifiable example of your attempt and say specifically where you're stuck. People will be glad to help. But for instance, for PHP to even get the fields above, you're going to need a
form
and a means of submitting it. PHP also uses a specific naming convention for repeated fields, etc. Any decent PHP form tutorial should cover these basics.– T.J. Crowder
Nov 20 at 8:47
Your best bet here is to do your research, search for related topics on SO, and give it a go. If you get stuck and can't get unstuck after doing more research and searching, post a Minimal, Complete, and Verifiable example of your attempt and say specifically where you're stuck. People will be glad to help. But for instance, for PHP to even get the fields above, you're going to need a
form
and a means of submitting it. PHP also uses a specific naming convention for repeated fields, etc. Any decent PHP form tutorial should cover these basics.– T.J. Crowder
Nov 20 at 8:47
1
1
@T.J.Crowder I made changes to my code, on the beginning you can PhP code, that is the part of where I get stacked.
– Mahmut
Nov 20 at 9:06
@T.J.Crowder I made changes to my code, on the beginning you can PhP code, that is the part of where I get stacked.
– Mahmut
Nov 20 at 9:06
|
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388891%2fget-values-from-other-table-columns-if-row-is-checked%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Even if you are new to programming: what have you tried on your own? Where exactly are you stuck?
– Nico Haase
Nov 20 at 8:27
1
I'm voting to close this question as off-topic because even the OP admits it's not the correct way to ask questions.
– Ken Y-N
Nov 20 at 8:28
1
@T.J.Crowder I prefer to be done in PhP
– Mahmut
Nov 20 at 8:43
Your best bet here is to do your research, search for related topics on SO, and give it a go. If you get stuck and can't get unstuck after doing more research and searching, post a Minimal, Complete, and Verifiable example of your attempt and say specifically where you're stuck. People will be glad to help. But for instance, for PHP to even get the fields above, you're going to need a
form
and a means of submitting it. PHP also uses a specific naming convention for repeated fields, etc. Any decent PHP form tutorial should cover these basics.– T.J. Crowder
Nov 20 at 8:47
1
@T.J.Crowder I made changes to my code, on the beginning you can PhP code, that is the part of where I get stacked.
– Mahmut
Nov 20 at 9:06