Ask a Question related to Coldfusion - Getting Started, Design and Development.
-
Droopers #1
Updating multiple values from a query
Hi all,
I'm looking for a way to update multiple lines in a database using a form.
While I've had no trouble updating single records, this whole multiple thing
throws me for a major loop. The query is based on a yes/no field in the
database (pulling all records that = yes), and the changes I am trying to make
are using a cfinput checkbox, so I'm not sure on how to specify the records
that need to be adjusted. Essentially I'd like to be able to remove entries
from the query by unchecking the checkbox and clicking a form submit, and to
have this work when I uncheck multiple records at once.
Ideally I'd like the submit to return to the same page (as it is right now ),
which also raises the question of how to have the logic pick up the values
submitted by the form so that it doesn't update everytime the page loads.
Thanks a pile for the help - I'm such a newbie:)
<cfparam name="issueYES" default="YES">
<!--- will update thisWeek field when form is submitted --->
<cfif some sort of condition is true>
<cfquery datasource="wrf">
UPDATE commentArticles
SET thisWeek = #FORM.thisWeek#
</cfquery>
</cfif>
<!--- queries thisWeek for page output --->
<cfquery name="currentIssue" datasource="wrf">
SELECT * FROM commentArticles INNER JOIN authors ON authors.authorID =
commentArticles.authorID
WHERE thisWeek = #issueYES#
ORDER BY articleID DESC
</cfquery>
<!---Output begins --->
<cfform action="comment.cfm">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<cfoutput query="currentIssue">
<cfif currentIssue.currentrow mod 2 eq 1><tr
bgcolor="##D6D6D6"><cfelse> <tr></cfif>
<td width="5%"><cfinput
type="checkbox" name="thisWeek" value="checkbox" checked="#thisWeek#"></td>
<td width="75%"><span class="style9"><a
href="##"><strong>#currentIssue.ArticleTitle#
#currentIssue.ArticleSubtitle#</strong></a>
<br>
<span
class="style10">posted by </span></span><span class="style10">#firstName#
#lastName#</span><span class="style9"></span></td>
<td width="20%" align="left"
valign="top"><span class="style9"><a
href="dingo.cfm?ID=#URLEncodedFormat(articleID)#"> <img src="../images/edit.gif"
width="14" height="16" border="0" class="floatLeft">Edit</a><br>
<br>
<a
href="dingo.cfm?ID=#URLEncodedFormat(articleID)#"> <img
src="../images/delete.gif" width="16" height="16" border="0"
class="floatLeft">Delete</a></span><br>
</td>
</tr>
</cfoutput>
</table>
<br>
<cfinput type="submit" name="Submit" value="Update'This Week'">
Droopers Guest
-
update query not updating
Hi I am trying to update via an datagrid only nothing seems to happen how would I diplay what the update query looks like msgbox reponse.write?... -
CAML Query: Multiple Query Fields Issue
I need to Create a CAML Query Dynamically with VB to a Sharepoint WebService GetListItems Method. The User Could Select 1 to X Number of IDs... -
Multiple select listbox values in query
I have two listboxes, the first of which is an autopostback=true that allows multiple row selection. When I select multiple values (by holding down... -
updating values in a $_SESSION array
I've been working on a webshop, and I've got most of the functionality up and running. One problem, however, that I don't seem to be able to solve... -
Updating dataset with values from TextBox control
Hi I have built a very simple page, which takes data via TextBox controls, and updates to a Dataset. I've used the Data Access Blocks (v2), to...



Reply With Quote

