<?php
include 'Connection.php';
if(isset($_REQUEST["insert"]))
{
$user = $_GET['user'];
$pwd = $_GET['pass'];
$sql = "select RegNo,UserName,password from Std_Reg where Username= '$user' and Password = '$pwd'";
//$sql = "select * from Std_Reg";
$stmt = sqlsrv_query($conn, $sql);
$result = array();
do {
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)){
$result[] = $row;
}
} while (sqlsrv_next_result($stmt));
if(count($result)>0)
{
$result1['status']=1;//"Login successfully";
array_push($result,$result1);
}
else
{
$result1['status']=0;//"Record not found";
array_push($result,$result1);
}
sqlsrv_free_stmt($stmt);
sqlsrv_close($conn); //Close the connnectiokn first
echo json_encode($result); //You will get the encoded array variable
}
?>
This gives me:
[{"RegNo":"xyz","UserName":"abc","password":"123"},{"status":1}].
I need:
[{"status":1},{"RegNo":"xyz","UserName":"abc","password":"123"}].
how can I get the above result? What should I change in the PHP file?