简体   繁体   中英

Unable to alert the message by capturing the array value in php using javascript.

    foreach ($record_sets as $row) {
        $params->Loginname = "a";
        $params->Password = "xxxxxxx";
        $params->studentresult = "<a1><marks>95</marks><grade>A</grade></a1>"; 
        $params->rollid = $row[0];

        $response = $client->Marksofstudent($params);
        $result = $response->Marksresult->SqlXml->any;

        var_dump($result);    

        if (strpos($result, 'error') === false) {
        /* do nothing */
    }  else {
        $array = array(
                    "marks" => $row[0],
                    "Subject"  => $row[1]
                 );
    ?> 
    <script>
    message = 'failure to post for ' + <?php echo $array->$row[0]; ?> + 'reportid and ' + '<?php echo $array->row[1]; ?>' +  'certificatenumber';
    adiha_CreateMessageBox('alert', message);
    </script>
<?php } } ?>
    }

I want to prompt the message after execution of the foreach loop and capture those all $row[0] and $row[1] value and alert the message 'Unable to $row[0] and $row[1] combination update'. Currently in the above code, i cannot get the $row[0] and $row[1] value.

I want a message like 'Unable to upload marks 1 subject x marks 2 subject y'.

I have no idea what you are doing but if you want to use the data you are adding to the array you have to change your code:

else {
    $array = array(
        "marks" => $row[0],
        "Subject"  => $row[1]
    );
?> 
<script>
    message = 'failure to post for ' + <?php echo $array['marks']; ?> + 'reportid and ' + '<?php echo $array['Subject']; ?>' +  'certificatenumber';
    adiha_CreateMessageBox('alert', message);
</script>

Or use $row[0] and $row[1] instead if you do not use the array otherwise in your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM