Jump to content

nsstudio

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

nsstudio's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi everyone! I'm trying to integrate my PHP/mySQL member billing system with an XML payment gateway (specifically, Orbital Paymentech). They've given me sample XML request & response templates, but I'm just not sure how that fits into my PHP page. I have a PHP form where a user fills in their credit card info, but when they click "Submit" the data needs to be transmitted as XML, and then an XML response will be sent back to the PHP page that needs to be parsed. Can anyone point me in the right direction? I assume this is simple, I've just never worked with XML in a PHP environment. Thanks for any help you can provide!
  2. That's what I thought... So now my question is, can anyone help me with the subquery? I've seen them done, but never using a SUM field, and am not quite sure what order to put the queries in. Thanks again for all your help!
  3. Thanks! I tried that, but no luck... I'm wondering if it has to do something with the type of join, or if I have to do a nested query... Anyone have any ideas?
  4. I'm having trouble getting a query to work, and would love some help... Basically, I'm trying to build a PHP "Accounts Receivables" report to see what clients owe money, and how much. I have three tables: "clients" with the client's ID, name, address, etc; "projects" which has a field called price, among others, and contains multiple projects per client; and "payments" which keeps track of all client payments and has an amount field, amont others. I'm trying to have a report that lists the client ID, name, total price, and total payments. Then I'll have a separate PHP variable to subtract the total payments from the total price and display the balance. Here is my current code... It works fine if I remove the third JOIN table and the SUM(payments.amount), but as soon as I add those, it multiplies the sum values of both price and payments by the number of returned rows, and all the numbers are inaccurate. For example, if the SUM(projects.price) "should" be $500 and there were two payments made for $250 each, it will list both sums as $1000. Does anyone have any ideas? Below is my current query: SELECT clients.id, clients.name, SUM(projects.price), SUM(payments.amount) FROM clients LEFT JOIN projects ON clients.id=projects.client_id LEFT JOIN payments ON projects.client_id=payments.client_id GROUP BY clients.id
  5. PLEASE HELP! This is sooo frustrating... I've created a search form that allows users to search a variety of fields - the more crietria they type in the narrower the results get. Dreamweaver MX has created the code, and it works, HOWEVER it won't return any results that have a NULL value for any of the query variables. For example, let's say I have a simple mySQL table that has the fields "name_first", "name_last", and "address". And I have 3 records - the first two have values for all three fields, and the third record only has first & last name but the address is NULL. If I do any kind of search, with or without search criteria, that third record doesn't show up. Here's my Dreamweaver-created code for the RESULTS page (only relevant code is included below): <?php require_once('../Connections/bhleadmin.php'); ?> <?php $colnamefirst_rsStaff = "%"; if (isset($HTTP_POST_VARS['name_first'])) { $colnamefirst_rsStaff = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['name_first'] : addslashes($HTTP_POST_VARS['name_first']); } $colnamelast_rsStaff = "%"; if (isset($HTTP_POST_VARS['name_last'])) { $colnamelast_rsStaff = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['name_last'] : addslashes($HTTP_POST_VARS['name_last']); } $coladdress_rsStaff = "%"; if (isset($HTTP_POST_VARS['address'])) { $coladdress_rsStaff = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['address'] : addslashes($HTTP_POST_VARS['address']); } mysql_select_db($database_bhleadmin, $bhleadmin); $query_rsStaff = sprintf("SELECT * FROM staff WHERE name_first LIKE '%%%s%%' AND name_last LIKE '%%%s%%' AND address LIKE '%%%s%%' ORDER BY id ASC", $colnamefirst_rsStaff,$colnamelast_rsStaff,$coladdress_rsStaff); $rsStaff = mysql_query($query_rsStaff, $bhleadmin) or die(mysql_error()); $row_rsStaff = mysql_fetch_assoc($rsStaff); $totalRows_rsStaff = mysql_num_rows($rsStaff); I've been experimenting with variations of "IS NULL" so that if no criteria is submitted for that field in the search form, then it will return both % and NULL fields, but I can't seem to get it to work. Here is one of the many variations I tried (I threw out all of the Dreamweaver code) - in this case the records with NULL fields DID show up, but then my search criteria had no effect - all the records showed up no matter what I searched for. <?php require_once('../Connections/bhleadmin.php'); ?> <?php if (strlen($_POST['address']) <> "") $varaddress = "address LIKE " + $_POST['address']; else $varaddress = "(address LIKE '%' OR address IS NULL)"; $customquery = "$varaddress"; mysql_select_db($database_bhleadmin, $bhleadmin); $query_rsStaff = ("SELECT * FROM staff WHERE $customquery ORDER BY id ASC"); $rsStaff = mysql_query($query_rsStaff, $bhleadmin) or die(mysql_error()); $row_rsStaff = mysql_fetch_assoc($rsStaff); $totalRows_rsStaff = mysql_num_rows($rsStaff); This seems like the most basic function - can anyone out there help? I've gotten this to work in the past using ASP: <%@LANGUAGE="VBSCRIPT"%> <!--#include file="../Connections/clients.asp" --> <% Set rsResults = Server.CreateObject("ADODB.Recordset") rsResults.ActiveConnection = MM_clients_STRING rsResults.Source = "SELECT * FROM Clients" dim appendSymbol appendSymbol = " WHERE " if (Request.Form("Name") <> "") then rsResults.Source = rsResults.Source + appendSymbol + "Name LIKE '%" + Request.Form("Name") + "%'" if (appendSymbol = " WHERE ") then appendSymbol = " AND " end if if (Request.Form("Sex") <> "") then rsResults.Source = rsResults.Source + appendSymbol + "Sex LIKE '" + Request.Form("Sex") + "'" if (appendSymbol = " WHERE ") then appendSymbol = " AND " end if rsResults.CursorType = 0 rsResults.CursorLocation = 2 rsResults.LockType = 1 rsResults.Open() rsResults_numRows = 0 %> Any help is sincerely appreciated, as I'm stuck on this project until I can figure this out! Thanks in advance!
×
×
  • 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.