PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 29th, 2011, 04:54 AM
worldbadger worldbadger is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2011
Posts: 1 worldbadger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 52 sec
Reputation Power: 0
Forms: POST & GET - 10 Drop Down Boxes - How to Prepare for Insertion to MySQL

I have a form with a text box and 10 drop down boxes (all with identical information in them. Here is the code for a small section;
<FORM METHOD="Post" ACTION=".........">
<input name="action" type="hidden" value="update">
<input name="rows" type="hidden" value="2" />

<table border=0>

<tr>
<td><INPUT Name="id[]" TYPE="Hidden" VALUE="1" /></td>
<td colspan="10"><input name="delegation[]" type="text" size="50" value="Advocate" /></td>
</tr>
<tr>
<td>
<select name="forum1Advocate">
<option value="NULL">--- Choose ---</option>
<option value="Advisory Panel">Advisory Panel</option>
<option value="Disarmament Commission">Disarmament Commission</option>
<option value="Economic and Social Council">Economic and Social Council</option>
<option value="Environment Commission">Environment Commission</option>
<option value="Executive Student Officer">Executive Student Officer</option>
<option value="General Assembly">General Assembly</option>
<option value="General Assembly First Committee">General Assembly First Committee</option>
<option value="General Assembly Second Committee">General Assembly Second Committee</option>
<option value="General Assembly Third Committee">General Assembly Third Committee</option>
<option value="Human Rights Council">Human Rights Council</option>
<option value="International Court of Justice">International Court of Justice</option>
<option value="Press">Press</option>
<option value="Security Council">Security Council</option>
<option value="Special Conference Sub-Commission 1">Special Conference Sub-Commission 1</option>
<option value="Special Conference Sub-Commission 2">Special Conference Sub-Commission 2</option>
<option value="Youth Assembly">Youth Assembly</option>
<option value="Youth Assembly Committee 1">Youth Assembly Committee 1</option>
<option value="Youth Assembly Committee 2">Youth Assembly Committee 2</option>
<option value="Youth Assembly Committee 3">Youth Assembly Committee 3</option>
<option value="Youth Assembly Committee 4">Youth Assembly Committee 4</option>
<option value="Youth Assembly Committee 5">Youth Assembly Committee 5</option>
</select>
<td>
<select name="forum2Advocate">
<option value="NULL">--- Choose ---</option>
<option value="Advisory Panel">Advisory Panel</option>
<option value="Disarmament Commission">Disarmament Commission</option>
<option value="Economic and Social Council">Economic and Social Council</option>
<option value="Environment Commission">Environment Commission</option>
<option value="Executive Student Officer">Executive Student Officer</option>
<option value="General Assembly">General Assembly</option>
<option value="General Assembly First Committee">General Assembly First Committee</option>
<option value="General Assembly Second Committee">General Assembly Second Committee</option>
<option value="General Assembly Third Committee">General Assembly Third Committee</option>
<option value="Human Rights Council">Human Rights Council</option>

When I begin to process this I am having troubles getting the code to prepare the values for inserting into an existing mySQL database.

if ($_POST['action']=='update') {

$err = array();

foreach($_POST as $key => $value) {
$data[$key] = filter($value); // post variables are filtered
}

$nmrw = $data['rows'];
$i = 0;
while($i < $nmrw){
$id = $_POST['id'][$i];
$delegation = $_POST['delegation'][$i];
$forum1 = $_POST['forum1'][$delegation];
$forum2 = $_POST['forum2'][$delegation];
$forum3 = $_POST['forum3'][$delegation];
$forum4 = $_POST['forum4'][$delegation];
$forum5 = $_POST['forum5'][$delegation];
$forum6 = $_POST['forum6'][$delegation];
$forum7 = $_POST['forum7'][$delegation];
$forum8 = $_POST['forum8'][$delegation];
$forum9 = $_POST['forum9'][$delegation];
$forum10 = $_POST['forum10'][$delegation];

mysql_query("update delegations set delegation = '$delegation', forum1 = '$forum1', forum2 = '$forum2', forum3 = '$forum3', forum4 = '$forum4', forum5 = '$forum5', forum6 = '$forum6', forum7 = '$forum7', forum8 = '$forum8', forum9 = '$forum9', forum10 = '$forum10' WHERE id = '$id'") or die(mysql_error());
$i++;
}
}
?>

Can anyone see where I have made the mistake. The delegation saves with no problem but all the forums are empty so they save nothing.

worldbadger

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Forms: POST & GET - 10 Drop Down Boxes - How to Prepare for Insertion to MySQL


Developer Shed Advertisers and Affiliates


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

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


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap