Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 以所需格式将数据从MySQL导出到文本文件_Php_Mysql - Fatal编程技术网

Php 以所需格式将数据从MySQL导出到文本文件

Php 以所需格式将数据从MySQL导出到文本文件,php,mysql,Php,Mysql,嘿,伙计们,我的项目需要一些帮助 我的PHP代码——下面这些代码从我的数据库中获取特定数据,由于规范化,我在join中使用了两个表。它显示我在浏览器中获取的数据以供检查,我希望将所选数据保存到具有特定格式的文本文件中。请参阅下面的其他详细信息。 谢谢,我收到了。。。这是正确的答案我一直在寻找我的问题。。我的好朋友帮助我 if($resultjoin->num\u rows>0){ $currentRowId=''; $output=''; 而($row=$resultjoin->fetch_a

嘿,伙计们,我的项目需要一些帮助

我的PHP代码——下面这些代码从我的数据库中获取特定数据,由于规范化,我在join中使用了两个表。它显示我在浏览器中获取的数据以供检查,我希望将所选数据保存到具有特定格式的文本文件中。请参阅下面的其他详细信息。
谢谢,我收到了。。。这是正确的答案我一直在寻找我的问题。。我的好朋友帮助我

if($resultjoin->num\u rows>0){
$currentRowId='';
$output='';
而($row=$resultjoin->fetch_assoc()){
如果($row[“id”]==$currentRowId){
echo','.$row[“产品标识”];
$output=$output.,'.$row[“产品标识”];
}else if($currentRowId==''){
$currentRowId=$row[“id”];
echo$row[“产品标识”];
$output=$output.$row[“产品标识”];
}否则{
$currentRowId=$row[“id”];
回显“
”.$row[“产品id”]; $output=$output.PHP_EOL.$row[“产品id”]; } } echo$输出; fwrite($fp,$output); }否则{ 回显“0结果”;
}
谢谢,我知道了。。。这是正确的答案我一直在寻找我的问题。。我的好朋友帮助我

if($resultjoin->num\u rows>0){
$currentRowId='';
$output='';
而($row=$resultjoin->fetch_assoc()){
如果($row[“id”]==$currentRowId){
echo','.$row[“产品标识”];
$output=$output.,'.$row[“产品标识”];
}else if($currentRowId==''){
$currentRowId=$row[“id”];
echo$row[“产品标识”];
$output=$output.$row[“产品标识”];
}否则{
$currentRowId=$row[“id”];
回显“
”.$row[“产品id”]; $output=$output.PHP_EOL.$row[“产品id”]; } } echo$输出; fwrite($fp,$output); }否则{ 回显“0结果”;
}
就我所见,您实际上就在那里-您只需要执行一些字符串操作,以便在将输出保存到file@kerry谢谢我试图做一些研究,但我解决不了。我不太擅长逻辑。我很难将你的实际输出与期望的结果进行比较,也很难理解你4是订单id,2是订单项属于4,3是订单项也属于4……等等……然后我看到4,24,35,15,25,65,56是实际输出,期望的输出似乎没有逻辑关系。在数据库表中,在不同的行中有两个4订单id。第一个是按项_排序的“2”,第二个是按项_排序的“3”。就我所见,您实际上就在那里-您只需要执行一些字符串操作,以便在将其保存到file@kerry谢谢我试图做一些研究,但我解决不了。我不太擅长逻辑。我很难将你的实际输出与期望的结果进行比较,也很难理解你4是订单id,2是订单项属于4,3是订单项也属于4……等等……然后我看到4,24,35,15,25,65,56是实际输出,期望的输出似乎没有逻辑关系。在数据库表中,在不同的行中有两个4订单id。第一个订单为“2”,第二个订单为“3”。