scarezekiel Posted July 2, 2012 Share Posted July 2, 2012 okay so i have like 4 datas in my db. but it only shows 1 in the page..how to fix this <?php require("html2fpdf.php"); $description = trim($_POST[district]); $server = ''; $username = ''; $password = ''; $database_name=''; $dbconn = mysql_connect($server, $username,$password,false) or die("Could not establish connection"); mysql_select_db($database_name, $dbconn) or die ("Could not select database"); if (!$dbconn) { die('Something went wrong while connecting to MSSQL'); } ob_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title></title> </head> <body> <? $query="SELECT * FROM tblaccassetregister"; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { $accassetgroupid = $row['accassetgroupid']; $assetcode = $row['assetcode']; $description = $row['description']; $purchaseprice = $row['purchaseprice']; $purchasedate = $row['purchasedate']; $serialno = $row['serialno']; $locationid = $row['locationid']; } ?> <table style="text-align: left; width: 715px; height: 32px;" border="0" cellpadding="2" cellspacing="2"> <tbody> <tr> <th align="left" colspan="2" style="font-style: italic;">Asset Group :</th> <? echo "<td align='left'>$accassetgroupid</td>"; ?> </tr> <tr> <th align="left" colspan="2" style="font-style: italic;">Description :</th> <? echo "<td align='left'>$description</td>"; ?> </tr> <tr> <td bgcolor="#00000" height="1px" colspan="5" rowspan="1"></td> <td bgcolor="#00000" height="1px" colspan="5" rowspan="1"></td> </tr> <br /> <tr class="even"> <th align="left" colspan="2" style="font-style: italic;">Asset Code :</th> <? echo "<td align='left' colspan='3'>$assetcode</td>"; ?> <th align="left" colspan="2" style="font-style: italic;">Purchase Date :</th> <? echo "<td align='left'>$purchasedate</td>"; ?> </tr> <tr class="odd"> <th align="left" colspan="2" style="font-style: italic;">Description :</th> <? echo "<td align='left' colspan='3'>$description</td>"; ?> <th align="left" colspan="2" style="font-style: italic;">Purchase Price :</th> <? echo "<td align='left'>$purchaseprice</td>"; ?> </tr> <tr class="even"> <th align="left" colspan="2" style="font-style: italic;">Location :</th> <? echo "<td align='left'>$locationid</td>"; ?> <th align="left" colspan="2" style="font-style: italic;"></th> <th align="left" colspan="2" style="font-style: italic;">Total Cost :</th> <? echo "<td align='left'>$purchaseprice</td>"; ?> </tr> </tbody> </table> <br> </body> </html> <?php $var = ob_get_clean(); $pdf = new HTML2FPDF('P', 'mm', 'Letter'); $pdf->AddPage(); $pdf->WriteHTML($var); $pdf->Output('test.pdf', 'I'); ?> i tried to attach a photo of it but dont know why this site cant upload it. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted July 2, 2012 Share Posted July 2, 2012 You're looping over the results, but not doing anything with them, so only the last record is there when you start to echo them. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.