Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 <html>
- 2 <body>
- 3 <?php include("head.php"); ?>
- 4
- 5 <?php
- 6
- 7 $con = mysql_connect("localhost","rtpr222","deathcab@4");
- 8 if(!$con)
- 9 {
- 10 die('Could not connect: ' . mysql_error());
- 11 }
- 12
- 13 mysql_select_db("rtpr222",$con);
- 14
- 15 //store table names in an array
- 16
- 17
- 18 //THIS FUNCTION PUTS TABLE NAMES IN AN ARRAY
- 19 /////////////////////////////////////////////
- 20 $numTables = 0;
- 21 $sql = "SHOW TABLES FROM rtpr222";
- 22 $result1 = mysql_query($sql);
- 23 $tableArray;
- 24 $tableArray = array();
- 25 while($row = mysql_fetch_row($result1)){
- 26
- 27 $tableArray[$numTables] = $row[0];
- 28 $numTables = $numTables + 1;
- 29 }
- 30 /////////////////////////////////////////////
- 31
- 32
- 33 $totalPaid = 0;
- 34 $ctr = 0;
- 35
- 36 while($ctr < $numTables){
- 37 $result = mysql_query("SELECT * FROM $tableArray[$ctr]
- 38 WHERE month = '$_GET[month]' AND paid = '0'" );//CHANGE TO 1
- 39 $cost = mysql_fetch_array($result);
- 40 $totalPaid = $totalPaid + $cost['cost'];
- 41 //echo "{$cost['cost']}";
- 42 $ctr = $ctr+1;
- 43 }
- 44
- 45 echo $totalPaid;
- 46
- 47 ?>
- 48 </body>
- 49 </html>
- ~
Add Comment
Please, Sign In to add comment