View Full Version : Adding Dropdown to Exisiting Insert Record page
Intrigue25
08-06-2009, 02:01 PM
I have a insert record already in place for a website i created with webAssist. My client would like to add a category dropdown box on the insert & update record page.
I already have the recordset populating the dropdown box (form the categories Table) and the field in the Database but when i sumbit the record to be added to the database nothing gets add to the field. My column name in the database is categoryName and it is set to varchar (255).
When i open the Insert Record Wizard I see the category Column - Type is set to text - value is set to <?php echo((isset($_POST["category"]))?$_POST["category"]:"") ?>
I would like the actual name to insert into the CategoryName Column - not the id
I need to set the same for the update page.
Eric Mittman
08-07-2009, 10:35 AM
To get the name inserted rather than the id you would just need to adjust the dynamic properties of the select list so that both the label and value were referencing the same column from your category table. What do you currently have for the values of this category select list?
As a way of testing the query that is being executed you can add in a die statement to print out the sql. Find the $WA_Sql variable that holds the query toward the bottom of the insert server behavior. Add in a new line after this and add the die statement like this:
die($WA_Sql);
You can examine the sql for problems, if you don't see any you can post it back here so others can take a look and try to find any problems.
Intrigue25
08-07-2009, 12:02 PM
Eric,
I added your code to the server behavior, but it doesn't do anything and sends me to the results page with the record added.
I labeled the code where i added the die($WA_Sql); Note: I did not add the spcing on top and bottom.
P.S. Attached is an image of my dynamic dropdown box. The Value is categoryName and the id is categoryName.
<?php
// WA Application Builder Insert
if (isset($_POST["Insert_x"])) // Trigger
{
$WA_connection = $products;
$WA_table = "Specials";
$WA_sessionName = "Insert_Specials";
$WA_redirectURL = "Specials_Results.php";
$WA_keepQueryString = false;
$WA_indexField = "id";
$WA_fieldNamesStr = "Title|descript|category|insideDim|outsideDim|photo 1|photo2";
$WA_fieldValuesStr = "".((isset($_POST["Title"]))?$_POST["Title"]:"") ."" . "|" . "".((isset($_POST["descript"]))?$_POST["descript"]:"") ."" . "|" . "".((isset($_POST["category"]))?$_POST["category"]:"") ."" . "|" . "".((isset($_POST["insideDim"]))?$_POST["insideDim"]:"") ."" . "|" . "".((isset($_POST["outsideDim"]))?$_POST["outsideDim"]:"") ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult2"]["serverFileName"] ."";
$WA_columnTypesStr = "',none,''|',none,''|',none,''|',none,''|',none,''| ',none,''|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_products;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
die($WA_Sql); <-- Inserted your code here without top and bottom spaces -->
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
Thanks
paul.casbourne361959
08-09-2009, 10:17 AM
Hi,
I notice that your $WA_fieldValuesStr contains value ["category"] but you mention your sql filed name is CategoryName.
I would make both these the same name, e.g. ["categoryName"]
Paul.
Intrigue25
08-10-2009, 06:36 AM
I have 2 tables. 1 for the Categories and 1 Specials. I am pulling the info from the Categories table to populate the dropdown box (i.e. id and CategoryName) In the specials table i would like to insert the CategoryName from the dropdown into the specials table under the Category Column.
So Paul, I think that is correct if I would want to put the value form the dropdown box into the Specials table into the column catergory. Is that correct?
paul.casbourne361959
08-10-2009, 11:52 AM
That would make sense.
Your dropdown field is named the same as the sql table field.
Can you post back the contents of your dropdown and category recordset?
Eric Mittman
08-10-2009, 01:29 PM
When you get to the results page are you now getting the name inserted instead of the id? Based on your screen shot of the select list dynamic dialog you should only have the name for both the label and value. If you are still getting the id this would indicate that the page has not been updated on the server. Based on the code you have with the die statement it should not get past this, a die statement is meant to stop all processing that is occurring on the page once it is called. Make sure that you have all of the pages uploaded to your server before you test this out and let us know the result. If you can post back with a link to the page, or at least the source code for the select list on the live page.
Intrigue25
08-10-2009, 01:33 PM
The value form the dropdown box does not post to the special Table (catergory). It's just not inserting the category name into the column.
I have done this before writting PHP code. But now that this site is built using DataAssist I am having toruble. I really dont wnat to redo the page. This should be easy to add with the DataAssist Wizard but something is not making the value add to the database.
Eric Mittman
08-10-2009, 01:53 PM
Based on the result you are reporting it seems that you the page you have on the live server does not match what you have posted here. I have opened a support ticket for you on issue. Please login to WebAssist.com and visit your support history to update the ticket. I would like to have a copy of the insert page to examine on my end.
Intrigue25
08-10-2009, 02:01 PM
Eric,
After i placed the die($WA_Sql); it did process and go to the results page. It didn't seem to change anything. The form still processes.
Here is the Code for the select list. I cna not post the code for the Live Page because it is in a secure area and when i right click and choose view page source it brings me to an access Check failed page.
<select name="category" id="category">
<?php
do {
?>
<option value="<?php echo $row_rs_category['categoryName']?>"><?php echo $row_rs_category['categoryName']?></option>
<?php
} while ($row_rs_category = mysql_fetch_assoc($rs_category));
$rows = mysql_num_rows($rs_category);
if($rows > 0) {
mysql_data_seek($rs_category, 0);
$row_rs_category = mysql_fetch_assoc($rs_category);
}
?>
</select>
Web assist just sent me an email for a ticket - I will foloow up there
Eric Mittman
08-10-2009, 05:20 PM
I will be posting back here when we come to a resolution on this issue. Please make any updates to your ticket so we have your most current files and any other requested details.
Eric Mittman
08-12-2009, 10:29 AM
We spoke on the phone and were able to debug the insert. After adjusting the action of the form and printing out the insert statement we were able to confirm that the code was working correctly.
One thing that we discussed was to leave the form action blank if you want the page to post to itself, and if you need to do some debugging in the php code you can use the die() function to print out a message or query for you.
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.