hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Proper SQL syntax to use with PHP?
Reply

Forum Jump

Proper SQL syntax to use with PHP?

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 02-15-2007, 12:53 PM
crEA-tEch crEA-tEch is offline
WHT Addict
 
Join Date: Aug 2003
Location: Walsall - UK
Posts: 171

Proper SQL syntax to use with PHP?


Hi guys.. I'm after a bit of help if possible..

I've got a SQL query that querys a database using PHP..

PHP Code:
$week_one "SELECT COUNT(service_price) AS one FROM figures WHERE service_sku='$service_sku_queried' AND week='1' ORDER BY service_description ASC"
It is then formatted to output a table as follows (if you can imaginea table):

SERVICE DESCRIPTION__________________UNITS IN WEEK 1___UNITS IN WEEK 2 TOTAL
--------------------------------------------------------------------------------------------------------------------
FULL SYSTEM RECOVERY______________________________3_______________1______4
SYSTEM RECASE____________________________________2________________0______2
etc......
etc.....
---------------------------------------------------------------------------------------------------------------------

(sorry for underscores.. forum wont allow me more than one space)


This goes on and on for every service.

Problem is ... I have refunds and sales. In the database it is either a regular positive number - or as a refund - a negative number.

Above for example has outputted 4 units for FULL SYSTEM RECOVERY ... but in my database there are 3 sales.. Three in week 1, and 1 in week 2.

My problem is... That one unit in Week 2 is a refund.. How can I make it output as negative number " - 1 " ??

Is there a function in COUNT at all?

I'm really confused!



Nick



Sponsored Links
  #2  
Old 02-15-2007, 08:36 PM
horizon horizon is offline
Web Hosting Master
 
Join Date: Mar 2006
Posts: 961
If you have set a primary key + auto_increment over your figures table, it is unlikely possible to set a -1. In order to do this, you must not set auto_incrementation on your table to achieve this.

Reply

Related posts from TheWhir.com
Title Type Date Posted
Cyberthreat Information Sharing Doesn't Break Antitrust Law: Feds Web Hosting News 2014-04-10 17:10:30
Email Outage Hits Intermedia Users, Network Issues to Blame Web Hosting News 2013-09-04 10:37:28
Five Rules for Moving to the Cloud Blog 2013-07-24 09:27:00
HostingCon 2013: The Coming Hybrid Wave - Colocation and the Cloud Web Hosting News 2013-06-21 17:12:32
How Rackspace's Study Can Help Web Hosts Prepare for the E-Commerce Holiday Season Web Hosting News 2012-10-30 13:59:47


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?