Click to See Complete Forum and Search --> : can 2 form fields have same name and send data to same db field?
jarow
02-09-2003, 12:53 PM
I need to create 3 separate text fields, the contents of which all need to be sent to one field in my mysql database...any ideas on how I may accomplish this in dreamweaver mx? and how I get the mysql database to accept three values?
Many thanks
Jim
autocolismo
02-10-2003, 05:10 PM
$value_to_mysql = $_GET['textfield1'] . $_GET['textfield2'] . $_GET['textfield3'];
then
insert into your_table set value = '$value_to_mysql';
Jim_Madrid
02-11-2003, 05:11 AM
Thank you for your response. I understand the concept but I am having trouble incorporating it into the Dreamweaver INSERT RECORD syntax. Let´s say I have the following code for:
Database table: session database field = animals
Form Textfield1 = animals
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO session (animals) VALUES (%s)",
GetSQLValueString($HTTP_POST_VARS['animals'], "text"));
mysql_select_db($database_conntest, $conntest);
$Result1 = mysql_query($insertSQL, $conntest) or die(mysql_error());
}
Now, if I have two more form textfields that I want to insert into one database field I imagine I would have to create something like this:
$habitat=$_GET[‘habitat1’] . =$_GET[‘habitat2’]
INSERT INTO session (habitat) VALUES ('$habitat’)
How and where do I put this exactly ?
Again thanks for your reply.
Jim
autocolismo
02-11-2003, 05:26 AM
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
$habitat = $_POST['habitat1'] . $_POST['habitat2'] . $_POST['habitat3'];
$insertSQL = sprintf("INSERT INTO session set animals='$habitat'";
mysql_select_db($database_conntest, $conntest);
$Result1 = mysql_query($insertSQL, $conntest) or die(mysql_error());
}
I think this workx fine:)
Jim_Madrid
02-12-2003, 04:15 AM
muito obrigado....it works like a charm
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.