0

here is where I get the values of the checkboxes. It is working. `

                    echo "<div class='table-responsive' >";
                          echo "<table class='table table bordered' style='font-size: 14px'>";
                          echo "<th style = ''> Action</th>"; 
                          echo "<th style = ''>Document</th>"; 
                    echo "</div>";

                        $cntr = 1;

                while ($row = sqlsrv_fetch_array($loadDocs)) 
                        {
                        echo "<tr>"; 

                        echo "<td  style = 'text-align:center;width:10%'>
                        <input type='checkbox' id='NAMING".$cntr."' value='".$row['DocCode']."' /></td>";
                        echo"<td  style = 'width:10%''>".$row["DocDesc"]."</td>";

                        echo "</tr>"; 
                        $cntr++;
                      }
                      ?>`

Help this is my php code for the selection and insertion of checkbox values in mssql stored procedure. I cant figure out what is wrong with the code. Please help.

`<?php

 if(isset($_POST['BTN_Proceed']))
 {
      $x=1;
      $BankName = $_POST['BankName'];
      $BankCode = $_POST['BankCode'];
      $DocCode  = $_POST['DocCode'];
      $rowCount = $_SESSION["rowCount"];

      while ($x < $rowCount)
          {
                    $insertDocsParam = array(array($BankName,SQLSRV_PARAM_IN),
                                                array($BankCode,SQLSRV_PARAM_IN),
                                                array($Doccode,SQLSRV_PARAM_IN),
                                                array($_POST["NAMING".$x],SQLSRV_PARAM_IN),);

                    $insertDocs = sqlsrv_query($conn, '{CALL sp_SRP_Insert_Doc (?,?,?,?)}', $insertDocsParam) or 
                    die( print_r( sqlsrv_errors(), true));;
                    $x++;
          }
      }   
?>`

This is my Stored Procedure for the insert query what else do I need to add here? Because Im also getting the checkbox data from sql server.

`ALTER PROCEDURE [dbo].[sp_SRP_Insert_Doc] 
(@BankName nvarchar(50),@BankCode nvarchar(5),@DocCode nvarchar(5))

AS
BEGIN
SET NOCOUNT ON;
    BEGIN
INSERT INTO [dbo].[ZREF_ROUT_INCO_DOC]
(BankName,BankCode,DocCode)

    VALUES
    (@BankName,@BankCode,@DocCode)
    END

END`
  • 2
    What exactly is or isn't working? – Dale K Nov 23 '18 at 02:38
  • When I select a checkbox then clicked the proceed button, theres no respond in the BTN_Proceed. I cannot add data in sp_SRP_Insert_Doc. I want to display the value of the checkbox="checked" in the database. – Joseph Escosura Nov 23 '18 at 02:41
  • Have you tested the SP standalone from SSMS? – Dale K Nov 23 '18 at 02:42
  • Yes. I will attach the SP in my post. – Joseph Escosura Nov 23 '18 at 02:45
  • I don't know PHP but based on this (you can google for more) are you 100% sure you are using the correct syntax to call SQL Server? https://stackoverflow.com/questions/31575135/how-to-execute-a-stored-procedure-in-php-using-sqlsrv-and-style-parameters – Dale K Nov 23 '18 at 02:54

0 Answers0