我有一个SQL命令,用于显示所有用户和所有操作。 但实际发生的是它只显示用户的最新行条目,而不是所有条目。
我的SQL是;
package com.example.phonesecurityassessment;
import android.content.ContentResolver;
import android.media.audiofx.BassBoost.Settings;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ContentResolver cr = getContentResolver();
int lockPatternEnable = Settings.Secure.getInt(cr, Settings.Secure.LOCK_PATTERN_ENABLED);
if (lockPatternEnable==1)
{
//lock pattern enabled
}
if (lockPatternEnable==0)
{
//lock pattern disabled
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
然后我将其作为;
输出到表格中$stmt=
"
SELECT *
FROM Actions
FULL OUTER JOIN Users
ON Actions.userID=Users.id;
";
$query = sqlsrv_query($link,$stmt);
$row = sqlsrv_fetch_array($query);
非常感谢任何建议。
-
期望的结果:
while($row = sqlsrv_fetch_array($query,SQLSRV_FETCH_ASSOC))
{
echo '<td>' . $row['id'] . '</td>';
...
}
-
实际值:
ID | USER | ACTION | TIME
1 Alpha Logged-in 00:00
2 Bravo Pswd Change 00:00
1 Alpha Logged-out 00:01
答案 0 :(得分:1)
似乎这样:
$query = sqlsrv_query($link,$stmt);
$row = sqlsrv_fetch_array($query);
第二行消耗了数组的第一行。是
这会使缓冲区中的指针前进(我不是PHP人)。因此,while()循环从第2行开始。