Insert value of one field into each selected field from list box... |
8/12/2007 12:46:47 AM |
PHPRunner General questions | |
D
daveDiamond author
I have a client that would like to record the total number of people for their form submission into a specific field in the database from which items for a list box are called. See the form here. Notice the Total Volunteers field, this will be a numeral, of course. Below this field are the Shifts for which the submitter may choose as many as necessary. These shifts are called from the _decorating_shifts table where the lookup table command will only display those entries WHERE "total_signed_up <= '50' ". This table also contains the finite value of volunteers allowed for each shift. It's column name is total_volunteers. |
|
V
|
Vladimir 8/13/2007 |
Dave, global $conn; $shifts = explode(",", $values["Shifts"]) for ($i=0,$i<count($shifts),$i++) { $strQuery = "select * from decorating_shifts where Decorating_Shift='".$shifts[$i]."'"; $rs = db_query($strQuery,$conn); if ($data=db_fetch_array($rs)) { $strSQLUpdate = "update decorating_shifts set Total_Signed_Up=Total_Signed_Up+".$values["Total_volunteers"]." where Decorating_Shift='".$shifts[$i]."'"; db_exec($strSQLUpdate,$conn); } else { $strSQLInsert = "insert into decorating_shifts (Decorating_Shift , Total_Signed_Up ) values ('".$shifts[i]."', ".$values["Total_volunteers"].")"; db_exec($strSQLInsert,$conn); } } return true; |
D
|
daveDiamond author 8/13/2007 |
Vladimir, function BeforeAdd(&$values) PHP error happened Technical information Error type 256 Error description You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 2 URL davediamondonline.com/dev/kiwanis_rose_parade_float_registration_page_add.php? Error file /homepages/13/d120330494/htdocs/dev/include/dbconnection.php Error line 26 SQL query insert into `kiwanis_rose_parade_float_registration_page` Solution This is a general error. It occurs when thereis an error in event code or in SQL. Send your SQL or event code along with full error message tosupport@xlinesoft.com.
|
J
|
Jane 8/14/2007 |
Dave, |
D
|
daveDiamond author 8/14/2007 |
Dave, Please publish your project on Demo Account and post a URL to your pages here. I'll find what's wrong with your project inspecting it at Demo account site.
|
J
|
Jane 8/15/2007 |
Dave, $values["total_volunteers_1"] |
D
|
daveDiamond author 8/15/2007 |
Doh! function BeforeAdd(&$values)
|
D
|
daveDiamond author 8/15/2007 |
No matter what I try, I can't seem to get this emailing thing right. I wish there were clearer documentation on how to call values from the database. If there is, please point me to it. My code below doesn't insert the db values for each email I want to BCC. Instead it just prints the var name. //********** Send email with new data ************
|
J
|
Jane 8/16/2007 |
Dave, //** Send email with new data **** global $conn; $strSQL = "select * from _global_options"; $rs = db_query($strSQL,$conn); while ($data = db_fetch_array($rs)) { $bcc1 = $data["global_email1"]; $bcc2 = $data["global_email2"]; $bcc3 = $data["global_email3"]; } $email=$values["email_1"]; $message="We've received your registration. Below is a copy of the form you submitted for your records.\r\n\r\n"; $subject="Your Kiwanis Rose Float Decoration Confirmation"; //**** Additional Headers **** $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers = 'From: Kiwanis Rose Float Registration <noreply@kiwanisrosefloat.com>' . "\r\n"; //$headers .= 'Cc: dave@voicedave.com' . "\r\n"; $headers .= "Cc: ".$bcc1.",".$bcc2.",".$bcc3."\r\n"; foreach($values as $field=>$value) $message.= Label($field)." : ".$value."\r\n"; $message.= "\r\nAll " .$values["total_volunteers_1"] . " of your volunteers must stay for the entire shift for each day listed above.\r\n\r\nThank you again for your registration. We'll see you there!"; mail($email, $subject, $message, $headers); |
D
|
daveDiamond author 8/16/2007 |
Dave, try to use this code:
function AddOnLoad()
|
D
|
daveDiamond author 8/20/2007 |
BUMP |
J
|
Jane 8/21/2007 |
Dave, global $conn; $strSQLone = "select * from _global_options"; $rsOne = db_query($strSQLone,$conn); while ($data = db_fetch_array($rsOne)) $global_total = $data["global_total_volunteers"]; $strTotal = "select SUM(total_signed_up) as sumTotal from _decorating_shifts"; $rsTotal = db_query($strTotal,$conn); while ($dataTotal = db_fetch_array($rsTotal)) $vol_total = $dataTotal["sumTotal"]; if ($vol_total >= $global_total) { ?><script> window.location='oops.php'; </script><?php exit; }
|
D
|
daveDiamond author 8/28/2007 |
Jane, Vladimir, et al.. |