Click here to Skip to main content
15,891,033 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: Call to Member function execute() on null... Pin
Richard MacCutchan27-Feb-17 6:49
mveRichard MacCutchan27-Feb-17 6:49 
GeneralRe: Call to Member function execute() on null... Pin
Richard Deeming27-Feb-17 7:56
mveRichard Deeming27-Feb-17 7:56 
GeneralRe: Call to Member function execute() on null... Pin
samflex27-Feb-17 8:09
samflex27-Feb-17 8:09 
GeneralRe: Call to Member function execute() on null... Pin
samflex27-Feb-17 11:44
samflex27-Feb-17 11:44 
GeneralRe: Call to Member function execute() on null... Pin
Richard MacCutchan27-Feb-17 21:28
mveRichard MacCutchan27-Feb-17 21:28 
GeneralRe: Call to Member function execute() on null... Pin
Richard Deeming28-Feb-17 1:09
mveRichard Deeming28-Feb-17 1:09 
GeneralRe: Call to Member function execute() on null... Pin
samflex28-Feb-17 1:23
samflex28-Feb-17 1:23 
GeneralRe: Call to Member function execute() on null... Pin
Richard Deeming28-Feb-17 1:40
mveRichard Deeming28-Feb-17 1:40 
Start by rendering all of the required fields, with the correct names and values:
PHP
<?php foreach ($rowIDs as $id) { ?>
<input type="hidden" name="rowIDs[]" value="<?php echo $id; ?>">
<input type="hidden" name="<?php echo 'sourcename' . $id ?>" value="<?php echo $_POST['sourcename' . $id]; ?>">
<input type="hidden" name="<?php echo 'sourceaddress' . $id ?>" value="<?php echo $_POST['sourceaddress' . $id]; ?>">
<input type="hidden" name="<?php echo 'income' . $id ?>" value="<?php echo $_POST['income' . $id]; ?>">
<?php }?>

<?php foreach ($row2IDs as $id) { ?>
<input type="hidden" name="row2IDs[]" value="<?php echo $id; ?>">
<input type="hidden" name="<?php echo 'spousename' . $id ?>" value="<?php echo $_POST['spousename' . $id]; ?>">
<input type="hidden" name="<?php echo 'spouseAddress' . $id ?>" value="<?php echo $_POST['spouseAddress' . $id]; ?>">
<input type="hidden" name="<?php echo 'spouseIncome' . $id ?>" value="<?php echo $_POST['spouseIncome' . $id]; ?>">
<?php } ?>

In final.php, you read them using the same code:
PHP
$rowIDs = $_POST['rowIDs'];
foreach ($rowIDs as $id) {
    $sourcename = $_POST['sourcename' . $id];
    $sourceaddress = $_POST['sourceaddress' . $id];
    $income = $_POST['income' . $id];
    ...
}

$row2IDs = $_POST['row2IDs'];
foreach ($row2IDs as $id) {
    $spousename = $_POST['spousename' . $id];
    $spouseAddress = $_POST['spouseAddress' . $id];
    $spouseIncome = $_POST['spouseIncome' . $id];
    ...
}

The only slight issue is that you won't be able to have the source and spouse on the same row in your database table, because they're independent lists. You'll have to put them on different rows:
PHP
$sql = 'INSERT INTO `myDB`.`wp_myTable` ( `employeeID`'
     . ', `sourcename`, `sourceaddress`, `income` )'
     . ' VALUES ( ? , ? , ? , ? )';

if( $sth = mysqli_prepare($conn,$sql) ) {
    mysqli_stmt_bind_param($sth, 'ssss',
        $last_id,
        $sourcename,
        $sourceaddress,
        $income);
    
    $rowIDs = $_POST['rowIDs'];
    foreach ($rowIDs as $id) {
        $sourcename = $_POST['sourcename' . $id];
        $sourceaddress = $_POST['sourceaddress' . $id];
        $income = $_POST['income' . $id];
        mysqli_stmt_execute($sth);
    }
    
    mysqli_stmt_close($sth);
}

$sql = 'INSERT INTO `myDB`.`wp_myTable` ( `employeeID`'
     . ', `spousename`,`spouseAddress`,`spouseincome` )'
     . ' VALUES ( ? , ? , ? , ? )';

if( $sth = mysqli_prepare($conn,$sql) ) {
    mysqli_stmt_bind_param($sth, 'ssss',
        $last_id,
        $spousename,
        $spouseAddress,
        $spouseIncome);
    
    $row2IDs = $_POST['row2IDs'];
    foreach ($row2IDs as $id) {
        $spousename = $_POST['spousename' . $id];
        $spouseAddress = $_POST['spouseAddress' . $id];
        $spouseIncome = $_POST['spouseIncome' . $id];
        mysqli_stmt_execute($sth);
    }
    
    mysqli_stmt_close($sth);
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: Call to Member function execute() on null... Pin
samflex28-Feb-17 3:30
samflex28-Feb-17 3:30 
GeneralRe: Call to Member function execute() on null... Pin
Richard Deeming28-Feb-17 3:39
mveRichard Deeming28-Feb-17 3:39 
GeneralRe: Call to Member function execute() on null... Pin
samflex28-Feb-17 4:00
samflex28-Feb-17 4:00 
GeneralRe: Call to Member function execute() on null... Pin
Richard Deeming28-Feb-17 4:11
mveRichard Deeming28-Feb-17 4:11 
GeneralRe: Call to Member function execute() on null... Pin
samflex28-Feb-17 4:28
samflex28-Feb-17 4:28 
GeneralRe: Call to Member function execute() on null... Pin
Richard Deeming28-Feb-17 4:32
mveRichard Deeming28-Feb-17 4:32 
GeneralRe: Call to Member function execute() on null... Pin
samflex28-Feb-17 5:38
samflex28-Feb-17 5:38 
QuestionGetting "Notice: Undefined offset: 1" error (SOLVED) Pin
samflex21-Feb-17 6:12
samflex21-Feb-17 6:12 
AnswerRe: Getting "Notice: Undefined offset: 1" error Pin
Richard Deeming21-Feb-17 8:37
mveRichard Deeming21-Feb-17 8:37 
GeneralRe: Getting "Notice: Undefined offset: 1" error Pin
samflex21-Feb-17 8:46
samflex21-Feb-17 8:46 
GeneralRe: Getting "Notice: Undefined offset: 1" error Pin
Richard Deeming21-Feb-17 9:03
mveRichard Deeming21-Feb-17 9:03 
GeneralRe: Getting "Notice: Undefined offset: 1" error Pin
samflex21-Feb-17 9:12
samflex21-Feb-17 9:12 
GeneralRe: Getting "Notice: Undefined offset: 1" error Pin
Richard Deeming21-Feb-17 9:22
mveRichard Deeming21-Feb-17 9:22 
GeneralRe: Getting "Notice: Undefined offset: 1" error Pin
samflex21-Feb-17 9:34
samflex21-Feb-17 9:34 
GeneralRe: Getting "Notice: Undefined offset: 1" error Pin
Richard Deeming21-Feb-17 9:37
mveRichard Deeming21-Feb-17 9:37 
GeneralRe: Getting "Notice: Undefined offset: 1" error Pin
samflex21-Feb-17 10:04
samflex21-Feb-17 10:04 
GeneralRe: Getting "Notice: Undefined offset: 1" error Pin
Richard Deeming21-Feb-17 11:06
mveRichard Deeming21-Feb-17 11:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.