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.










share|improve this question




















  • 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















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.










share|improve this question




















  • 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













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.










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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














  • 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








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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'