我有一个基本的网页,其中有许多使用PHP查询CSV表的按钮。每个按钮后面都有它自己的PHP文件。
每个按钮/PHP的作用:如果CSV上的一行包含字符串,该行将回显到屏幕上。例如,按钮1将显示一个记录列表,其中列X包含字符串y
我的问题是,如果用户想要运行多个查询(同时混合查询),我有什么选择?我猜一种选择是将查询结果输出到一个临时文件,并在该文件上运行每个连续的查询,每次都重写它。但我只是想知道有没有什么"快速简单"的方法。MySQL不是一个选项。下面是代码的主要部分…谢谢!
$file = fopen("myfile.csv", "r"); //open the file
...
while (($line = fgetcsv($file)) !== FALSE){ //read through the file
...
foreach ($line as $elt) {
...
if ($line[X] == "myString") { // check column location X at each record for myString
echo "table border=..."; //clean up the output with some basic html rendering
echo $line[N]; //N will be the contents of a cell, print to screen
...
你应该替换
if ($line[X] == "myString")
if (in_array($line[X], $myQueries))
但问题是如何查询或"myString"目前传入脚本?
这将影响$myQueries(查询数组)的生成。