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 July 3rd, 2009, 07:47 AM
GBain21 GBain21 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 57 GBain21 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 16 m 35 sec
Reputation Power: 2
PHP5 - Using arrays and INSERT statements

Hi,

I have a table that lists orders from customers - I am supplying a checkbox next to each order, so that the administrator can tick multiple orders then click the submit button "Update orders" which then changes a field in the database to "yes" - to signify the order has been verfied. The checkbox code is as follows:

PHP Code:
echo '<td><input type="checkbox" name="order" value="'$orderID .'" /> 


The above code is located in my "while" loop so that $orderID comes straight from the row itself.

However, I can only get my code to actually perform an UPDATE statement on one of the fields when this is submitted.

PHP Code:
 UPDATE order_table SET ordered 'yes' WHERE order_id $orderID 


I need to find a way of storying the ticked checkboxes in an array?.. and then performing the UPDATE statement on multiple rows, instead of just one.

Any help would be greatly appreciated.

Reply With Quote
  #2  
Old July 3rd, 2009, 09:23 AM
chrisjacob.us chrisjacob.us is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2009
Location: United States
Posts: 68 chrisjacob.us User rank is Sergeant Major (2000 - 5000 Reputation Level)chrisjacob.us User rank is Sergeant Major (2000 - 5000 Reputation Level)chrisjacob.us User rank is Sergeant Major (2000 - 5000 Reputation Level)chrisjacob.us User rank is Sergeant Major (2000 - 5000 Reputation Level)chrisjacob.us User rank is Sergeant Major (2000 - 5000 Reputation Level)chrisjacob.us User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 21 h 17 m 32 sec
Reputation Power: 32
Make the checkboxes themselves as an array:
PHP Code:
echo '<td><input type="checkbox" name="order[]" value="'.$orderID.'" /></td>'


Then just loop through the array using a for statement or for each statement.

Reply With Quote
  #3  
Old July 3rd, 2009, 03:56 PM
GBain21 GBain21 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 57 GBain21 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 16 m 35 sec
Reputation Power: 2
Cheers

Quote:
Originally Posted by chrisjacob.us
Make the checkboxes themselves as an array:
PHP Code:
echo '<td><input type="checkbox" name="order[]" value="'.$orderID.'" /></td>'


Then just loop through the array using a for statement or for each statement.


Cheers dude

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP5 - Using arrays and INSERT statements


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-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
Stay green...Green IT