我想在php中使用分頁與使用ajax和數據來自文件。在搜索關鍵詞時,頁面顯示文件中的前20條記錄,但現在我希望文件中剩餘的下一條記錄,並且應該使用分頁。任何建議嗎?從文件分頁用php和ajax
$keyword=$_POST['data'];
$file = file_get_contents("http://localhost:8080/searchengine/searchDeals?searchKeyword=".$keyword."");
$output = "[";
$line = 1;
if (!($fp = fopen($file, "r")))
exit("Unable to open the input file.");
while(!feof($fp) && $line <= 20)
{
if($line != 20){
$output = $output.fgets($fp).",";
}else{
$output = $output.fgets($fp);
}
$line++;
}
fclose($fp);
$output = $output."]";
echo $output;
請隨意添加一些您嘗試過的代碼。 – Jesse
我手動使用現在我想用ajax來做。我發佈了我的手冊代碼 – Mayur
我已經完成了它從文件發送前20條記錄。到ajax,並在那裏desplays記錄 – Mayur