Darkmatter5 Posted October 30, 2008 Share Posted October 30, 2008 Here's my code <?php include 'library/config.inc.php'; $conn=mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); mysql_select_db($dbnamemain); $que_fols=mysql_query("SELECT folder_id, fol_name FROM folders JOIN cabinets ON(cabinets.cabinet_id=folders.cabinet_id) WHERE cab_name='Bills' ORDER BY fol_name ASC ") or die(mysql_error()); while($row1=mysql_fetch_array($que_fols)) { echo "<b>$row1[fol_name] ($row1[folder_id])</b><br>"; $que_years=mysql_query("SELECT DISTINCT item_id, folders.folder_id, fol_name, MID(bill_date_due,1,4) as year FROM items JOIN folders ON(folders.folder_id=items.folder_id) JOIN cabinets ON(cabinets.cabinet_id=folders.cabinet_id) WHERE cab_name='Bills' AND folders.folder_id=$row1[folder_id] ORDER BY fol_name ASC, year ASC ") or die(mysql_error()); while($row2=mysql_fetch_array($que_years)) { $que_data=mysql_query("SELECT bill_date_due, bill_amount FROM items WHERE folder_id=$row1[folder_id] AND item_id=$row2[item_id] ORDER BY bill_date_due ASC ") or die(mysql_error()); $dataset=array(); while(list($date,$amt)=mysql_fetch_row($que_data)) { $t=strtotime($date); $values=array ("year"=>date('Y',$t), "month"=>date('m',$t), "amount"=>$amt); $dataset[$values[month]]=$values[amount]; } $filename="images/graphs/$row1[folder_id]$row2[year].png"; //echo "<a href='$filename'> $row2[year]</a>"; print_r($row2); } /*if($dataset!=NULL) { echo " <a href='$filename'>$row2[year]</a>"; } else { echo "<i>No items exist in this bill folder!</i>"; }*/ echo "<p>"; } mysql_close($conn); ?> Here's what the print_r shows. Credit Card statements (14) Internet (15) Array ( [0] => 13 [item_id] => 13 [1] => 15 [folder_id] => 15 [2] => Internet [fol_name] => Internet [3] => 2008 [year] => 2008 ) Array ( [0] => 14 [item_id] => 14 [1] => 15 [folder_id] => 15 [2] => Internet [fol_name] => Internet [3] => 2008 [year] => 2008 ) Telephone (2) Array ( [0] => 15 [item_id] => 15 [1] => 2 [folder_id] => 2 [2] => Telephone [fol_name] => Telephone [3] => 2007 [year] => 2007 ) Array ( [0] => 9 [item_id] => 9 [1] => 2 [folder_id] => 2 [2] => Telephone [fol_name] => Telephone [3] => 2008 [year] => 2008 ) Array ( [0] => 11 [item_id] => 11 [1] => 2 [folder_id] => 2 [2] => Telephone [fol_name] => Telephone [3] => 2008 [year] => 2008 ) Array ( [0] => 12 [item_id] => 12 [1] => 2 [folder_id] => 2 [2] => Telephone [fol_name] => Telephone [3] => 2008 [year] => 2008 ) Water and Electric (10) Where should I place the "echo "<a href='$filename'> $row2[year]</a>";" line so that the output would be? Credit Card statements (14) Internet (15) 2008 Telephone (2) 2007 2008 Water and Electric (10) 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.