Get data from sql server using stored procedure php

I need to use a stored procedure to get data from an SQL server DB, I will then put the data in an HTML table. I can call to SQL server using a query but struggle to understand how to use a stored procedure, can anyone help?
Here is my code:

/* Empty data array */
$trackData = array( );

/* Connextion to SQL Server */
$server = 'tcp:address;

$credentials = array
  'UID'       => 'User',
  'PWD'       => 'password',
  'Database'  => 'myDB',
  'ReturnDatesAsStrings' =>1

$connection = sqlsrv_connect( $server, $credentials );

/* Get sql data */
global $connection;
$sqlForTrack ="StoredProc";
WHERE	Handle >0";
$queryForTrack = sqlsrv_query( $connection, $sqlForTrack );
/* Handle sql errors if retuned */
if( $queryForTrack === false )
        echo ("failed to load query");
        die( '<pre class="error">' . print_r( sqlsrv_errors(), true ) . '</pre>' );
            /* Handle sql response for track data */
            if( sqlsrv_num_fields( $queryForTrack ) )
                    echo "<thead>

                    while( $row = sqlsrv_fetch_array( $queryForTrack, SQLSRV_FETCH_ASSOC ) )
                            echo "<tbody>";
                            echo "<tr>";
                            echo "<td>" . $row['Track'] . "</td>";
                            echo "</tr>";
                            echo "</tbody";

                    echo "</table>";
    sqlsrv_free_stmt( $connectoin );
    sqlsrv_close ( $connection );

There will be more than one track and I want them to display on my table. The problem is I don’t understand how to give the stored proc the date variable, which is the parameter it needs to give me the tracks. Then output the tracks to my table.
I really appreciate any guidance.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.