close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Adding Dropdown to Exisiting Insert Record page

Thread began 8/06/2009 2:01 pm by Intrigue25 | Last modified 8/12/2009 10:29 am by Eric Mittman | 4034 views | 11 replies |

Intrigue25

Adding Dropdown to Exisiting Insert Record page

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.

Sign in to reply to this post

Eric Mittman

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.

Sign in to reply to this post

Intrigue25

Adding Die Statement

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|photo1|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

Sign in to reply to this post

PaulBeta Tester

possible solution

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.

Sign in to reply to this post

Intrigue25

? on Possible Solution

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?

Sign in to reply to this post

PaulBeta Tester

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?

Sign in to reply to this post

Eric Mittman

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.

Sign in to reply to this post

Intrigue25

No!

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.

Sign in to reply to this post

Eric Mittman

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.

Sign in to reply to this post

Intrigue25

Code 1

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

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...