sammie Posted April 12, 2007 Share Posted April 12, 2007 Hi, I used a PHP-MySQL wizard to generate a report, and it is formatted with 10 records per page like this: RECORD 1 Field1 Field2 Field3 RECORD 2 Field1 Field2 Field3 I'd like to be able to change the format so it prints 1 record per page like this: RECORD 1 Field1 Field2 Field3 NEW PAGE RECORD 2 Field1 Field2 Field3 I'd appreciate any help. Here is the code for the generated report: <?php $host='localhost'; $user='XXXX'; $pass='XXXX'; $db='XXXX'; $datasource='table'; $table=array('applicant'); $fields=array('a_lastname','a_firstname','a_middle','a_homephone','a_workphone','a_email','a_presentaddress','a_presentcity','a_presentstate','a_presentzip'); $group_by=array('a_lastname'); $sort_by=array(array('a_lastname','0'),array('a_firstname','0')); $layout='AlignLeft1'; $style_name='default'; $title='Data'; $date_created='12-Apr-2007 17:53:22'; $header=''; $footer='The Company'; $file_name='rpt_applicant'; $records_per_page='10'; ?> Link to comment https://forums.phpfreaks.com/topic/46780-change-format-of-a-php-report/ Share on other sites More sharing options...
tippy_102 Posted April 13, 2007 Share Posted April 13, 2007 To display one record per page, change the ten in the last line to a one. $records_per_page='1'; As for the formatting, it looks like that is controlled by this line: $layout='AlignLeft1'; The code you posted is from a config file. Post the file that contains the $layout function and we'll see if we can figure that out. Link to comment https://forums.phpfreaks.com/topic/46780-change-format-of-a-php-report/#findComment-228189 Share on other sites More sharing options...
sammie Posted April 13, 2007 Author Share Posted April 13, 2007 Thanks so much! Here is the AlignLeft1.php file: <?php /** * Generated by Smart Report Maker *All copyrights are preserved to StarSoft *http://mysqlreports.com/ * */ error_reporting(E_ERROR | E_PARSE); include_once("lib.php"); if(isset($_GET['start'])) {$start = $_GET['start'];} else { $start=0;} if(isset($_GET['print'])) {$print = $_GET['print'];} else $print=0; $link_home = $_SERVER["PHP_SELF"]; //*************************create sql statement ******************* if($datasource=='sql') { $sql = Prepare_QSql(); } else { $sql = Prepare_TSql(); } //get number of rows $result = query($sql); $nRecords = mysql_num_rows($result); //$$$ /* ***********begin of export section*********** */ if(isset($_GET['export'])) { $export = $_GET['export']; } else { $export = ""; } //export data if($export =='csv' ) { export_csv($sql,false,0,10); exit; } elseif($export == 'csv1') { export_csv($sql,true,$start,$records_per_page); exit; } else if($export=='xml') { export_xml($sql,false,0,10); exit; } elseif($export == 'xml1') { export_xml($sql,true,$start,$records_per_page); exit; } else if($export =='pdf1') { if(count($fields)> get_pdf($sql,'a4','landscape',10,10,10,10,780,800,10,11,true,$start,$records_per_page); else get_pdf($sql,'a4','portrait',10,10,10,10,490,500,9,10,true,$start,$records_per_page); exit; } else if($export =='pdf') { if(count($fields)> get_pdf($sql,'a4','landscape',10,10,10,10,780,800,10,11,false,$start,$records_per_page); else get_pdf($sql,'a4','portrait',10,10,10,10,490,500,9,10,false,$start,$records_per_page); exit; } //exporting links //current $link_pdf_current = $_SERVER["PHP_SELF"]."?export=pdf1&&start=$start"; $link_csv_current = $_SERVER["PHP_SELF"]."?export=csv1&&start=$start"; $link_xml_current = $_SERVER["PHP_SELF"]."?export=xml1&&start=$start"; //all $link_csv_all = $_SERVER["PHP_SELF"]."?export=csv"; $link_xml_all = $_SERVER["PHP_SELF"]."?export=xml"; $link_pdf_all = $_SERVER["PHP_SELF"]."?export=pdf"; // ********************************************/ //**************************print links****************************** $link_print1 = $_SERVER["PHP_SELF"]."?print=1&&start=$start"; $link_print2 = $_SERVER["PHP_SELF"]."?print=2"; $link_print_real = $_SERVER['PHP_SELF']."?print=3&start=$start"; //*************************next and prev links ********************* $next_start = $start+$records_per_page; if($next_start >= $nRecords) $next_start = $start; $link_next=$_SERVER["PHP_SELF"]."?start=$next_start "; $prev_start = $start - $records_per_page; if($prev_start < 0) $prev_start = 0; $link_prev=$_SERVER["PHP_SELF"]."?start=$prev_start"; //initiaize vars $cur_row = 0; $toggle_row = 0; //create new sql includes the start and end limits except in case print all if($print !=2) $sql .= " limit $start,$records_per_page"; $result = query($sql); $cur_group_ar=array(); // the current group $last_group_ar = array(); //the newest grou by fields $actual_fields = array_diff($fields, $group_by); //actual columns which will be shown without group by fields $actual_columns_count = count($actual_fields); //number of columns to be shown $group_by_count = count($group_by); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title><?php echo $title ?></title> <link href="<?php if($print!= 0) { echo "print.css" ; } else { echo $style_name . ".css" ; } ?>" rel="stylesheet" type="text/css" /> </head> <body class="MainPage"> <table border="0" <?php //width of report if($print != 0) echo "width='500'"; else echo "width ='100%'"; ?> align="center" cellpadding="2" cellspacing="0" class="MainTable" > <!-- ************************* Menu code **************************** !--> <?php if($print !=3 ) //not in real priting mode { ?> <tr> <td height="27" class="menu" colspan="<?php echo $actual_columns_count; ?>" id="menu_row"> <?php include("menu.php") ?></td> </tr> <?php } ?> <!-- *************************End Of Menu code **************************** !--> <!-- ******************** start custom header ******************** !--> <?php if(!empty($header)) { ?> <tr> <td colspan="<?php echo $actual_columns_count?>" valign="top" ><?php echo($header);?></td> </tr> <tr> <td colspan="<?php echo $actual_columns_count?>" valign="top" class="Separator" ></td> </tr> <?php } ?> <!-- ******************** end custom header ******************** !--> <tr> <td colspan="<?php echo $actual_columns_count?>" valign="top" class="Title" ><?php echo($title);?></td> </tr> <tr> <td class="Separator" colspan="<?echo $actual_columns_count?>"></td> </tr> <?php while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { //fill array with current grouping fields foreach($group_by as $key=>$val) { $cur_group_ar[$val] = $row[$val] ; } //print group by fields in case of grouping values variation if(count($last_group_ar)!=0) { $diff_index = grouping_diff_index($cur_group_ar,$last_group_ar); } else { $diff_index = 0 ; } if($diff_index !=-1) { for($i=$diff_index;$i<count($group_by);$i++) { if($i ==0 && $diff_index==0) echo "<tr><td class='MainGroup' colspan=". $actual_columns_count ." >" .$group_by[$i] .": " . $row[$group_by[$i] ] . " </td></tr>"; else echo "<tr><td class='SubGroup' colspan=". $actual_columns_count ." >" . $group_by[$i] .": " . $row[$group_by[$i] ] . "</td></tr>"; } //echo"<tr><td height='15' $span class='TableHeader'></td></tr>"; if($cur_row==0) { ?> <tr> <td><table <?php //width of report if($print != 0) echo "width='500'"; else echo "width ='100%'"; ?> border="0" cellspacing="0" cellpadding="2" align='center'> <?php } } ?> <?php //print table columns if( ($group_by_count>0 && $diff_index !=-1) || $cur_row==0 ) //if there is a change in grouping { $i = 0; foreach($actual_fields as $key=>$val) { if($i==0) echo "<tr>"; echo "<td align='center' class='ColumnHeader'>$val</td>"; if($i == $actual_columns_count -1) echo "</tr>"; $i++; } } //print row data echo "<tr>"; foreach($actual_fields as $key=>$val) { if($toggle_row == 0) if(empty($row[$val])) echo "<td align='center' class='TableCell'>" . " " . "</td>"; else echo "<td align='center' class='TableCell'>" . $row[$val] . "</td>"; else if(empty($row[$val])) echo "<td align='center' class='AlternateTableCell'>" . " " ."</td>"; else echo "<td align='center' class='AlternateTableCell'>" . $row[$val] ."</td>"; } echo "</tr>"; //change toggling of rows if($toggle_row == 0) $toggle_row = 1; else $toggle_row =0; //update new grouping if($diff_index !=-1) { $last_group_ar =array(); foreach($group_by as $key=>$val) { $last_group_ar[$val] = $row[$val] ; } } //increment current rows $cur_row ++; } ?> </table></td> </tr> <!-- ******************** start custom footer ******************** !--> <?php if(!empty($footer)) { echo "<tr><td > $footer</td></tr>"; } ?> <!-- ******************** end custom footer ******************** !--> <tr> <td class="TableFooter"> </td> </tr> </table> <!-- ************************* Show print Dialog **************************** !--> <?php //show print dialog in case of print mode $$$ if($print==3) { ?> <script> window.print(); </script> <?php } ?> <!-- ************************* End Of Show print Dialog ********************* !--> </body> </html> Link to comment https://forums.phpfreaks.com/topic/46780-change-format-of-a-php-report/#findComment-228528 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.