On the admin side of
the FAQ page I created I wanted the ability to change the order the questions
appeared. Just in case, "question 1" for some weird reason had to be in
"question 5" position on the FAQ display page. Bottomline I need the flexibilty
to move questions around on the FAQ display page.
The query
below is for the FAQ display page and outputs all questions based on the
"orderNum" value. The data type for the "orderNum" column is "int" ,
because it lists the values in order (i.e. 1,2,3,4,5,6,7,8,9,10).
<!--- FAQ CONTENT
--->
<CFQUERY NAME="faq" DATASOURCE="db">
SELECT *
FROM faq
ORDER BY orderNum
</CFQUERY>
<CFQUERY NAME="faq" DATASOURCE="db">
SELECT *
FROM faq
ORDER BY orderNum
</CFQUERY>
Problem is
that when I try to change the order through the processing
page "updateFaq.cfm" see code below:
<CFQUERY
NAME="updateOrder" DATASOURCE="db">
UPDATE faq
SET orderNum = '#orderNum#'
WHERE faqID = '#faqID#'
</CFQUERY>
UPDATE faq
SET orderNum = '#orderNum#'
WHERE faqID = '#faqID#'
</CFQUERY>
I get the
following error:
Syntax error
converting the varchar value '1,2,3,4,5,6,7,8,9,10,' to a column of data type
int
The page
preceding the "updateFaq.cfm" page is a simple form, see
below:
<CFQUERY
NAME="orderCount" DATASOURCE="db">
SELECT *
FROM faq
ORDER BY orderNum
</CFQUERY>
SELECT *
FROM faq
ORDER BY orderNum
</CFQUERY>
<cfoutput
query="orderCount">
<form name="form"
action="updateFaq.cfm" method="post">
<input type="hidden" name="faqID" value="#faqID#">
<input type="hidden" name="faqID" value="#faqID#">
<input
type="text" name="orderNum" size="5" maxlength="30"
value="#orderNum#">
<input
type="submit" value="Change Order">
</form>
</cfoutput>
If I change
the data type of the "orderNum" column to "text" then I can update it, but the
order comes out like this (1,10,2,3,4,5,6,7,8,9) on
the display page.
Hope this makes
sense. Thanks.
Arun
