PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 4th, 2005, 10:38 AM
Gavin83's Avatar
Gavin83 Gavin83 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 275 Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 4 h 49 m 12 sec
Reputation Power: 42
Update SQL query

Just a quick question. I have the following SQL query which updates the game covers in the database. However, I want it to see if a value has been entered, and if not, leave the current database entry as it is. Is there any value I could set into the variables $filename[1] and $filename[2] which'll leave the current database entries as they are? I cant really remove them from the query so Ideally Id like to do it this way.

Thanks for your help.

PHP Code:
 $query "UPDATE game_review SET us_cover='$filename[2]', eu_cover='$filename[1]' WHERE reviewID='$reviewID'"

Reply With Quote
  #2  
Old October 4th, 2005, 10:44 AM
bdreyer's Avatar
bdreyer bdreyer is offline
His name is Robert Paulson!
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2005
Location: Paper Street
Posts: 2,692 bdreyer User rank is First Lieutenant (10000 - 20000 Reputation Level)bdreyer User rank is First Lieutenant (10000 - 20000 Reputation Level)bdreyer User rank is First Lieutenant (10000 - 20000 Reputation Level)bdreyer User rank is First Lieutenant (10000 - 20000 Reputation Level)bdreyer User rank is First Lieutenant (10000 - 20000 Reputation Level)bdreyer User rank is First Lieutenant (10000 - 20000 Reputation Level)bdreyer User rank is First Lieutenant (10000 - 20000 Reputation Level)bdreyer User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 3 Days 4 h 10 m 43 sec
Reputation Power: 130
The only way would be to do a select statement against the db.
__________________
Environmental LIMS
What the hell is all this LIMS st*ff about?
---------------------------------------
PHP Pagination Function
PHP Drop Down Menus

Reply With Quote
  #3  
Old October 4th, 2005, 11:29 AM
Gavin83's Avatar
Gavin83 Gavin83 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 275 Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 4 h 49 m 12 sec
Reputation Power: 42
Right, ok, thats what I figured. I just wanted to check there wasnt some SQL code that just added the original entry back to the database.

Reply With Quote
  #4  
Old October 4th, 2005, 03:06 PM
Guelphdad's Avatar
Guelphdad Guelphdad is offline
Hockey face
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Nov 2001
Location: St. Catharines, Canada
Posts: 7,605 Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level)Guelphdad User rank is General 1st Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 4 Days 22 m 48 sec
Reputation Power: 1070
Here is an example, you may have to modify for your specific needs as you have not shown any data and I may be misinterpreting.

Say your U.S. mag can have any of a number of colors. If it is red you want to change it to orange, if it is blue you want to change it to green, if it is any other color you want to leave it as is.

sql Code:
Original - sql Code
  1. UPDATE
  2. yourtablename
  3. SET us_cover=
  4. (CASE
  5. WHEN us_cover='red' THEN 'orange'
  6. WHEN us_cover='blue' THEN 'green'
  7. ELSE us_cover END)


note there are no commas or anything needed within the case statement.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Update SQL query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 7 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek