이것은 내가 달성하고자하는 것입니다. 드롭 다운 메뉴에서 모두를 선택한 경우 데이터베이스에서 모든 클라이언트를 선택합니다. 각 클라이언트에 대해 스크립트를 실행하여 html 페이지와 pdf를 만듭니다. 이것은 내가해야하는 곳이지만 각 클라이언트에 대해 html 페이지와 pdf를 생성 할 수는 없습니다.각 루프의 PHP
<?php
$client_id=$_POST["client_id"];
$date_start=$_POST["date_start"];
$date_end=$_POST["date_end"];
if ($client_id == 'ALL')
{
$con = mysql_connect("localhost","user","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mydatabase", $con);
$query = "select client_id from ca_client_account";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$command="php $result.php $result $date_start $date_end > $result.html";
exec($command, $output, $status);
echo $command;
if ($status!=0) {print_r($output); die("wget failed with status $status"); }
$command="wkhtmltopdf-i386 --margin-left 5mm --margin-right 5mm $result.html $result.pdf";
exec($command, $output, $status);
if ($status!=0) die("htmltopdf failed");
}
}
else
{
$command="php $client.php $client_id $date_start $date_end > $client.html";
exec($command, $output, $status);
if ($status!=0) {print_r($output); die("wget failed with status $status"); }
$command="wkhtmltopdf-i386 --margin-left 5mm --margin-right 5mm $client.html $client.pdf";
exec($command, $output, $status);
if ($status!=0) die("htmltopdf failed");
}
?>
단일 클라이언트의 경우 모든 것이 완벽합니다. 내가 모든 클라이언트 진술을 시도하고 생성 할 때 나는 그것을 작동시키지 못한다.
내가 뭘 잘못하고 있니?
많은 감사
출력물은 무엇입니까? 오류가 있습니까? –
$ 결과 변수가 각 client_id를 의도 한대로 출력하지 않습니다. 그것은 호기심이 많은 자원 ID를 출력합니다. –
왜'exec' 파일을'include'하는 대신에 다른 파일처럼 실행합니까? 나에게 덜 번거로운 것처럼 보입니다. –