Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-13-2005, 11:48 AM Insert Help
Average Talker

Posts: 23
Trades: 0
With the below code it only inserts the last checkbox selected into the db, however if I spit the code out it shows all inserts strings generated. Any suggestions?

HTML Code:
<input name="state_rep[1]" type="checkbox" title="Alabama">AL&nbsp;
<input name="state_rep[2]" type="checkbox" title="Alaska">AK&nbsp;
<input name="state_rep[3]" type="checkbox" title="Aamerican Samoa">AS&nbsp;
<input name="state_rep[4]" type="checkbox" title="Arizona">AZ&nbsp;
<input name="state_rep[5]" type="checkbox" title="Arkansas">AR&nbsp;
<input name="state_rep[6]" type="checkbox" title="California">CA&nbsp;
<input name="state_rep[7]" type="checkbox" title="Colorado">CO&nbsp;
PHP Code:
<?
function update_person_detail_state_rep() {
global 
$defaults$_POST;
foreach(
$_POST['state_rep'] as $key => $value) {
echo 
"insert into person_state_rep (person_id, state_id) values ('".$_POST["id"]."', '".$key."')";
}
if (
mysql_connect($defaults["db_server"], $defaults["db_username"], $defaults["db_password"])) {
if (
mysql_select_db($defaults["db_database"])) {
if (
mysql_query($query)) {
}
else {
die (
"<h3>SQL Error #".mysql_errno()."</h3>\n<h4>".mysql_error()."</h4>\n<h4>Line ".__LINE__." in ".__FILE__."</h4>\n");
}
}
else {
die (
"<h3>SQL Error #".mysql_errno()."</h3>\n<h4>".mysql_error()."</h4>\n<h4>Line ".__LINE__." in ".__FILE__."</h4>\n");
}
}
else {
die (
"<h3>SQL Error #".mysql_errno()."</h3>\n<h4>".mysql_error()."</h4>\n<h4>Line ".__LINE__." in ".__FILE__."</h4>\n");
}
}
?>
tobeyt23 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Insert Help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10782 seconds with 12 queries