Guest User

Untitled

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