Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach ($_POST ["data"] as $id => $subs) {
- foreach ($subs as $key=>$sub) {
- $subcategory = $sub;
- if($subs['id']=="$subcategory"){
- echo $sql = " insert into x(kodLebuhraya,kodSeksyen) values ('".$subs['id']."','".$sub."')";echo "<br>";
- }else{
- //echo "hi2";
- echo $sql = " insert into x(kodLebuhraya,kodSeksyen) values ('".$subs['id']."','".$sub."')";echo "<br>";
- }
- }
- }
- <label>Set One</label>
- <input class="location" type="text" name="data[location][]" value=""/>
- <input class="shipval" type="text" name="data[shipval][]" value=""/>
- <label>Set Two</label>
- <input class="location" type="text" name="data[location][]" value=""/>
- <input class="shipval" type="text" name="data[shipval][]" value=""/>
- <label>Set Three</label>
- <input class="location" type="text" name="data[location][]" value=""/>
- <input class="shipval" type="text" name="data[shipval][]" value=""/>
- foreach ($_POST['data']['location'] as $key => $location) {
- $shipVal = $_POST['data']['shipval'][$key];
- //now you have a pair of $location and $shipVal
- echo $location.' : '.$shipVal.'<hr>';
- }
- $sql = "INSERT INTO x(`kodLebuhraya`,`kodSeksyen`) VALUES ('%s','%s')" ;
- printf($sql,mysqli_real_escape_string($_POST['data'][0]),mysqli_real_escape_string($_POST['data'][1]['id']));
- INSERT INTO x(`kodLebuhraya`,`kodSeksyen`) VALUES ('A','B')
- <form method="POST">
- A : <input id="location" type="text" name="data[]" value="" />
- B : <input id="shipval" type="text" name="data[][id]" value="" />
- <input id="shipval" type="submit" name="submit" value="Submit" />
- </form>
Add Comment
Please, Sign In to add comment