在php中逐条echo MySQL数组记录


echo MySQL array records one by one in php

我想知道如何echo一个数组记录一个接一个的按钮点击打印前进和后退记录。

$query = "SELECT * FROM printingorder WHERE recHead = 'Pending'";
$result = mysql_query($query);

如果我使用

while($postate = mysql_fetch_array($result)){ 
    echo  "<h4>" .'1. Faculty : '. $postate['facultyId'] ."</h4>";
    echo  "<h4>" .'2. Department : '. $postate['departmentId'] ."</h4>";
    echo  "<h4>" .'3. Programm : '. $postate['programmId'] ."</h4>";
}

在每个原始内容之后打印所有记录。但是,我只需要一个完整的原始内容和下一个原始的按钮点击(或超链接)的向前和反向数组记录。

你的查询应该是这样的:

$a = $_POST['row_number'];
$query = "SELECT * FROM printingorder WHERE recHead = 'Pending' limit $a,1";
$result = mysql_query($query);

在两个按钮(上一个和下一个)post整数值,这是行号。

 while($postate = mysql_fetch_assoc($result)){ 
    echo  "<h4>" .'1. Faculty : '. $postate['facultyId'] ."</h4>";
    echo  "<h4>" .'2. Department : '. $postate['departmentId'] ."</h4>";
    echo  "<h4>" .'3. Programm : '. $postate['programmId'] ."</h4>";
}

试试mysql_fetch_assoc