<?php
function conectarse()
{
if(!($link=mysql_connect("localhost","root","")))
{
echo "Error when connecting to Database";
exit;
}
if(!mysql_select_db("test",$link))
{
echo "Error when selecting Database";
exit;
}
return $link;
}
?>
<html>
<head>
<title>QUERY TO DB</title>
</head>
<body>
<h3>Example using Rpv and php</h3>
<?php
$fp = fopen("C:\Program Files\Rpv\reports\data.rpv", "w");
fwrite ($fp, "REPORT_TITLE=Report generated from php
$col_0=500
$col_1=2000
$col_2=4500
$col_3=7000
tm=350
pagelength=15000
pagewidth=11907
spacing=220
[HEADER]
{f=arial;s=14;a=c;\n}
{5500;b=y;c=2}DEVELOPERS REPORT {\n;\n;\n;b=n;c=0;s=8}
{xyline=500,700,10000,700}
{$col_0;b=y} CODE {$col_1} NAME {$col_2} PHONE {$col_3} ADDRESS {s=7;4000} {\n;b=n;s=8}
{xyline=500,1100,10000,1100} {\n}
[DATA]
");
$link=conectarse();
$resultado=mysql_query("select * from dbabel order by code", $link);
while($row=mysql_fetch_array($result))
{
echo " Ok. ";
fwrite ($fp, "{$col_0} $row[code] {$col_1} $row[name] {$col_2} $row[phone] {$col_3} $row[address] {\n}
");
}
fclose($fp);
mysql_free_result($result);
mysql_close($link);
?>
</table>
</body>
</html>
<?php
exec('C:\Progra~1\Rpv\Rpv.exe C:\Progra~1\Rpv\reports\data.rpv');
?> |
REPORT_TITLE=Report generated from php
$col_0=750
$col_1=2500
$col_2=4500
$col_3=7000
tm=350
pagelength=15000
pagewidth=11907
spacing=220
[HEADER]
{f=arial;s=14;a=c;\n}
{5500;b=y;c=2}DEVELOPERS REPORT {\n;\n;\n;b=n;c=0;s=8}
{xyline=500,700,10000,700}
{$col_0;b=y} CODE {$col_1} NAME {$col_2} PHONE {$col_3} ADDRESS {s=7;4000} {\n;b=n;s=8}
{xyline=500,1100,10000,1100} {\n}
[DATA]
{$col_0} 222{$col_1} Peter Thompson {$col_2} 123-456789{$col_3} Brown 556 {\n}
{$col_0} 111{$col_1} Adalberto Ordoñez J.{$col_2} 591-2-7061856{$col_3} Florida 1334 {\n}
{$col_0} 333{$col_1} Donal Waide {$col_2} 4555-8897{$col_3} Mozart 11 {\n} |