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`
5
  • 2
    What exactly is or isn't working? Commented Nov 23, 2018 at 2: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. Commented Nov 23, 2018 at 2:41
  • Have you tested the SP standalone from SSMS? Commented Nov 23, 2018 at 2:42
  • Yes. I will attach the SP in my post. Commented Nov 23, 2018 at 2: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? stackoverflow.com/questions/31575135/… Commented Nov 23, 2018 at 2:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.