Jump to content

tomtimms

Members
  • Posts

    114
  • Joined

  • Last visited

    Never

Posts posted by tomtimms

  1. So let me get this straight, you want a link that will take you to a page that will show even more information based on the product that was selected?  If that is the case then you need to have a field in your database that will contain an ID. 

  2. your while loop is before your html tag, this doesn't make any sense. try and put it after your <body> tag if you want to loop multiple tables for each customer

     

     

    <?PHP
    while($row = mysql_fetch_array($result)){
       echo "Customer: " . $row['Account_and_Name'];
    
       echo "<br />";
    ?>
    <table>
    <tr>
    <th>Month</th>
    <th>Gallons Sold</th>
    <th>Sales Dollars</th>
    <th>Cost of Goods Sold</th>
    <th>Gross Profit</th>
    <th>Profit Per Gallon</th>
    </tr>
    </table>
    <?PHP } ?>
    

  3. Thanks for the help, I was able to use the script posted and it works great, however what if the table doesn't exists?  I have a date range picker and I don't want to adjust it to only be able to select a specific date range.  How can I have it so that if a user selects current year and I only have 3 of the current 12 tables created that it won't show a sql error that the tables don't exists?

     

    I tried using

     

    while($current_table <= $end_table){
    
    $Table = mysql_query("show tables like '" . $current_table . "'");
    
    if(mysql_fetch_row($Table) === true) {
    
    $query .= "\n UNION SELECT *  FROM  reports_$current_table WHERE date BETWEEN '" .date("Y-m-d", strtotime($start)) . " 00:00:00' AND '" .date("Y-m-d", strtotime($end)) . " 23:59:59' AND source='" . $source . "' GROUP BY day(date)"; // append union query
    
    $current_table = next_table($current_table); // get the next table
    
    }
    }
    

     

    however it doesn't work.

  4. I wish I could be putting it into 1 table however there is going to be too much data.  Every month new tables will be created then eventually archived over time.  Any clue on where to begin?  I assume I would need to grab all the months/year and see how many there are between that range and get its value...

  5. I agree, however what if my date range is 01/01/2009 to 06/01/2010?  How could I obtain all the months in that date range then append it to my query to select each table for each month.  So I would be selecting from a total of 18 tables.  Just a starting point would be awesome from anyone.

  6. I need to run a query for a report, however it needs to be taken from 2 tables on the same database.  I have reports201005 and reports201006 as my tables (year and month).  Say I need to run a report that gets data from may 15th (reports201005) to june 15th (reports201006).  Each table has a date field (obviously), a total column, and a location column.  So my query would need to select date, total, location FROM reports201005 and reports201006 from the date range BETWEEN 05-15-2010 AND 06-15-2010.    Also keep in mind I have a table for each month so the user can also select a different date range.  I have been making this really complicated in my head and just need a solid starting point on where to begin.  Any logic would be great!

  7. here is my connection

     

    <?php

     

    function PPHttpPost($methodName_, $nvpStr_)

    {

     

        $API_UserName =

        $API_Password =

        $API_Signature =

        $API_Endpoint = "https://api-3t.paypal.com/nvp";

     

        $version = urlencode('51.0');

     

        // setting the curl parameters.

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $API_Endpoint);

        curl_setopt($ch, CURLOPT_VERBOSE, 1);

     

        // turning off the server and peer verification(TrustManager Concept).

        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

     

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        curl_setopt($ch, CURLOPT_POST, 1);

     

        // NVPRequest for submitting to server

        $nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";

     

        // setting the nvpreq as POST FIELD to curl

        curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);

     

        // getting response from server

        $httpResponse = curl_exec($ch);

     

     

        if (!$httpResponse) {

            exit("$methodName_ failed: " . curl_error($ch) . '(' . curl_errno($ch) . ')');

        }

     

        // Extract the RefundTransaction response details

        $httpResponseAr = explode("&", $httpResponse);

     

        $httpParsedResponseAr = array();

     

        foreach ($httpResponseAr as $i => $value) {

            $tmpAr = explode("=", $value);

            if (sizeof($tmpAr) > 1) {

                $httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];

            }

        }

     

        if ((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)) {

            exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.");

        }

     

        return $httpParsedResponseAr;

    }

    ?>

     

     

  8. I am currently using the Pay Pal API and whenever I go to the page that connects it shows the complete connection in my error log.  How can I prevent this?  Below is what is printed out.  I tried using "@" before each curl_ reference however this doesn't prevent the error from showing.

     

    Connected to api-3t.paypal.com (66.211.168.126) port 443

    * successfully set certificate verify locations:

    *  CAfile: /etc/pki/tls/certs/ca-bundle.crt

      CApath: none

    * SSL connection using DES-CBC3-SHA

    * Server certificate:

    *        subject: /C=US/ST=California/L=San Jose/O=PayPal, Inc./OU=Information Systems/CN=api-3t.paypal.com

    *        start date: 2009-09-24 00:00:00 GMT

    *        expire date: 2011-09-19 23:59:59 GMT

    *        issuer: /C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=Terms of use at https://www.verisign.com/rpa ©09/CN=VeriSign Class 3 Secure Server CA - G2

    * SSL certificate verify ok.

    > POST /nvp HTTP/1.1

    Host: api-3t.paypal.com

    Accept: */*

    Content-Length: 157

    Content-Type: application/x-www-form-urlencoded

     

    METHOD=GetBalance&VERSION=51.0&PWD=6SZ4PMFR7879HBDB&USER=****_api1.*****.com&SIGNATURE=AFcWxV21C7fd0v3bYYYRCpSSRl31Adju6w2eRqw.IhcgUi1iU1NUsGrQ< HTTP/1.1 200 OK

    < Date: Thu, 10 Jun 2010 18:51:58 GMT

    < Server: Apache

    < Content-Length: 140

    < Connection: close

    < Content-Type: text/plain; charset=utf-8

    * Closing connection #0

    * About to connect() to api-3t.paypal.com port 443

    *  Trying 66.211.168.126... * connected

    * Connected to api-3t.paypal.com (66.211.168.126) port 443

    * successfully set certificate verify locations:

    *  CAfile: /etc/pki/tls/certs/ca-bundle.crt

      CApath: none

    * SSL connection using DES-CBC3-SHA

    * Server certificate:

    *        subject: /C=US/ST=California/L=San Jose/O=PayPal, Inc./OU=Information Systems/CN=api-3t.paypal.com

    *        start date: 2009-09-24 00:00:00 GMT

    *        expire date: 2011-09-19 23:59:59 GMT

    *        issuer: /C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=Terms of use at https://www.verisign.com/rpa ©09/CN=VeriSign Class 3 Secure Server CA - G2

    * SSL certificate verify ok.

    > POST /nvp HTTP/1.1

    Host: api-3t.paypal.com

    Accept: */*

    Content-Length: 157

    Content-Type: application/x-www-form-urlencoded

     

  9. I thought I had it. How can I make this so that only "NET" is looped then I can put it all into a table?

     

    $sql = "SELECT company,net FROM accounts";

    $result = mysql_query($result);

     

    while ($array = mysql_fetch_array($result) {

     

    foreach ($array AS $i => $amt) {

    if ($amt > 10000) {

    $d = intval($amt/10000);

    $r = $amt % 10000;

    for ($i = 0;$i < $d;++$i) {

    echo "10,000<br>\n";

    }

    echo $r . "<br>\n";

    } else {

    echo $amt . "<br>\n";

    }

    }

    }

  10. It is for payments, no payment can be more than 10k.  So if I have a payment going out that is more 10,000 it has to be broken down to numbers less than 10,000 so they can be sent.  So if I had a payment of 25,000 I would need 10,000 - 10,000 - 5,000.

  11. I have a table something like below. I need to display these results into a table however any number that is greater than 10,000 I need it split up so the number cannot be greater than 10,000. I am not sure where to begin or how to do this as I would need it to look like the example below.

     

    Table:

     

    ID : Amount

    1 10,400

    2 8,000

    3 10,300

    4 5,000

    5 1,000

     

    Example Result/Display

     

    1 5,000

    1 5,400

    2 8,000

    3 5,000

    3 5,300

    4 5,000

    5 1,000

     

    Is this possible? If anyone could assist or give a helping hand on where to start I would be very thankful.

  12. My database is fine, I just shortened it up and changed things around to show what I am trying to accomplish.  yes and on file are fields that are required from a user in order for them to get paid.  So yes represents if they were verified and on_file represents there tax information.  If both of those are in the table then they get paid, however if they both are not then they don't.  I am trying to get a query that shows either 1.  there both missing and 2.  if they have one inserted, to get the field that is missing.  I hope that clears it up a little bit.

  13. I am trying to see if a database either doesn't have a record, or if it contains 1 of 2 results. 

     

    I have a total of 2 databases and there are joined by ID.  Database 1 contains the following.

     

    ID | Amount

    1    100

    2    200

    3    300

    4    400

    5    500

     

    Database 2 has

     

    ID : Type

    1 : on_file

    1:  yes

    2. on_file

    2: yes

    3: on_file

    4: yes

     

    I need a query that will join database 1 to database 2 on ID then it will return the results where ID doesn't have either "on_file" or "yes" or both.  So my results would end up like.

     

    ID | Misssing

    3    yes

    4    on_file

    5    yes,on_file

     

    I can't wrap my head around this on where to start, I figured out how to get the results where "on_file" and "yes" are both found however can't figure out how to get the results where they are not.  Any starting point would be great.

  14. I have a query

     

    SQL = SELECT id, fruit FROM account WHERE id >= 0

    result = mysql_query(sql);

    row = mysql_fetch_array(result);

     

    it returns

     

    ID  | Fruit

    1 , Orange

    2, Orange

    3, apple

     

    how can I store all the values in fruit ($fruit = $row['fruit]) into an array where it will be separated by a comma?  I want to count the number of occurrences Orange shows up and how many times Apple shows up.

  15. not sure what I am doing wrong, here is the compiled code.  Nothing is displaying.

     

    $sql = "SELECT status, COUNT(*) FROM accounts WHERE status > 0 GROUP BY status";
    $result = mysql_query($sql);
    
    $statusCount = array();
    while($row = mysql_fetch_assoc($result))
    {
        //Code to display the record
    
        $status = $row['status'];
       
    
        //Add to the status count
        if(!isset($statusCount[$status]))
        {
            $statusCount[$status] = 1;
            
        echo $statusCount['Status 1']; 
            
            
            
        }
        else
        {
            $statusCount[$status]++;
        }
        
    
        
    }

     

  16. This will create an array with the keys as the status description and the values as the count

     

    $statusCount = array();
    while($row = mysql_fetch_assoc($result))
    {
        //Code to display the record
    
        $status = $row['status'];
    
        //Add to the status count
        if(!isset($statusCount[$status]))
        {
            $statusCount[$status] = 1;
        }
        else
        {
            $statusCount[$status]++;
        }
    }

     

    thanks for the response, what would I echo out to get the count of how many times status 2 occured?

  17. I am trying to count how many times a certain result is returned in my while loop. 

     

    My query is "SELECT * FROM accounts WHERE status > 1"

     

    I use a while loop to display my data and the data when parsed looks like this.

     

    Company 1 - Status 2 - Green

    Company 2 - Status 2 - Yellow

    Company 3 - Status 3 - Blue

    Company 4 - Status 3 - Orange

    Company 4 - Status 2 - Black

     

    Status 2 occurs ?

    Status 3 occurs ?

     

    I want to count how many times Status 2 occurs and how many times status 3 occurs.  Is this possibly with my Query?  Right now I am using 2 queries and changes my where clause to "WHERE status =2 and status =3"  I want to only use 1 query for this.

  18. I have 2 queries that I would like to somehow condense into one as I don't want to make 2 calls to my database.

     

    My 2 queries are.

     

    $sql = "SELECT company FROM revenue_company WHERE status = '1'"; 

    $sql2 = "SELECT company FROM revenue_company WHERE status = '2'"; 

     

    and I just want to get the number of rows returned for each query so I have

    $row = mysql_num_rows($result);

    $row2 = mysql_num_rows($result2);

     

    There has to be an easier way for me to condence my query into 1 and get the amount of rows returned that either have a status of 1 or a status of 2.  Any suggestions would be great.

     

  19. I am trying to insert data from one table to the other, however I am having an issue that when I run my script 2 times it inserts the data twice.

     

    I have columns Date | ID | Revenue | Total in my Master table and I am trying to insert Date | ID | Revenue into another table. 

     

    Here is my query

    $sql = "INSERT IGNORE INTO my_accounting.company_revenue (date,id,total) SELECT date,id,total FROM my_accounting.master_revenue";
    

     

    My Master table has

    Date : Index

     

    And my Company Has

    Date: index

    id: index

    total: index

     

    Anyone know why I am getting double insertions?

  20. Ok so far I have this as my Form Code

     

    <html>
       <head>
          <title>Testing</title>
       </head>
       <body>
          <form action="processing.php" method="post">
             <?php
          
    while ($rows = mysql_fetch_assoc($result)){
    
                   echo '<input type="checkbox" name="cbox[]" value="' . $rows['company'] . '"> Adjustment: <input type="text" name="adjustment[]" size="5"> Company: '.$rows['name'].' <br>' . "\n";
                
                }
             ?>
             <input name="submit" value="Send Values" type="submit">
          </form>
       </body>
    </html>

     

    and this as my processing

    if (isset($_POST['submit'])) {
    
        if (isset($_POST['cbox'])) {
            
            
           foreach ($_POST['cbox'] as $i => $item) {
            
            
            $sql = "UPDATE revenue_company SET status = '1' ,adjustment = ".mysql_real_escape_string($_POST['adjustment'][$i])." WHERE company = ".$item."";
            $result = $db->db_query($sql);
            
            echo $sql;
    
           }
        }
    }

     

     

    My form display's 3 rows of data.  If you check the second row or third row that adjustment field doesn't process.  However if you select all 3 rows it works just fine.  Anyone know what's going on?

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.