ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old December 29th, 2004, 06:26 AM
Maximon Maximon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 2 Maximon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Update query problem including cfloop

Hey folks

Hey there. Thx for your info so far. I'm almost done wrapping down the code for that sh*tty thing

Here is wat i got NOW:
This would be my SPEdit.cfm

Code:
<cfquery name="getVorplan" datasource="DARVorplan">
SELECT *
FROM Sendeplan
ORDER BY Sendeplan.Order
</cfquery>
<cfquery name="Moderatoren" datasource="DAR">
SELECT DJName
FROM Moderatoren
WHERE Aktiv=TRUE
</cfquery>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Sendeplan bearbeiten</title>
</head>
<body>


<cfoutput>
	<CF_DOW Param="DOWFULL" Wotag=#id# VNAME="actWoTag"> 

	<table  border="1" class="lstUO">
	<tr><th width="50" scope="col">Zeit</th> <th width="100" scope="col">#actWoTag#</th><th width="80" scope="col">Sendung</th></tr>

<form name="form1" method="post" action="../login/SPProcess.cfm">
	<cfloop index="loopcount" from="1" to="#getVorplan.recordcount#">
		<tr>
			<td>#getvorPlan.Zeit[loopcount]#</td>
			<td>
				<cfset Moderator = StructNew()>
				<cfset Modi =#getVorplan[actWoTag]#>
				<select name="selModerator">
					<cfloop index="AnzModi" from="1" to="#Moderatoren.recordcount#">
				  		<option>#Moderatoren.DJName[AnzModi]#</option>
					</cfloop>
				  <option>Night-Stream</option>
				  <option>Ohne Moderation</option>
				  <option Selected>#Modi[loopcount]#</option>
				</select>
			</td>
			<td>
			<cfset MArt=#getVorplan["Art"&actWoTag][loopcount]#>
				<select name="ModiArt">
	  				<cfif MArt IS "T"><option selected>Thema</option>
							  		  <option>Special</option>
	  						  		  <option></option>
	  				<cfelseif MArt IS "S"><option selected>Special</option>
								  		  <option>Thema</option>
	  							 		  <option></option>
	  				<cfelseif MArt IS ""><option selected></option>
										 <option>Thema</option>
	  					   				 <option>Special</option>
	  				</cfif>
				</select>
			</td>
		</tr>
	</cfloop>


</cfoutput>
</table>



Now i got a question regarding this part up there. I got one select box which will set in a <td> from 1 to .recordcount. So after all i got 9 select boxes in the finished output.

Now i want to update the database with that information.

What do i got to do?
Right now i have this:
Thats my application.cfm

Code:
<cfquery name="getVorplan" datasource="DARVorplan">
SELECT *
FROM Sendeplan
ORDER BY Sendeplan.Order
</cfquery>
<cfloop index="VPU" from="1" to="#getVorplan.recordcount#">

<cfquery name="UpdateVorplan" datasource="DARVorplan">
UPDATE Sendeplan
SET Montag = '#selModerator#' , ArtMontag = '#ModiArt#'
</cfquery>
</cfloop>


But what it does, it writes all 9 select boxes in ONE Row, meaning:

Instead of updating info like this:

Zeit Montag ArtMontag
08-10 DJ1 Special
10-12 DJ2 Thema
it gives me this:

Zeit Montag
08-10 DJ1 DJ2
10-12 DJ1 DJ2

I know something is not running right, but how do i tell the update query which select box to take?
Because that sucka only got one name.. makes it difficult for me to understand

Already tried this here too:
SET Montag = '#selModerator[VPU]#' , ArtMontag = '#ModiArt[VPU]#'
because i need to get the index somehow.... but as soon as i put that in there i get this Error thats drivin' me nuts:

You have attempted to dereference a scalar variable of type class java.lang.String as a structure with members.


The error occurred in ..\SPProcess.cfm: line 10

8 : <cfquery name="UpdateVorplan" datasource="DARVorplan">
9 : UPDATE Sendeplan
10 : SET Montag = '#selModerator[VPU]#' , ArtMontag = '#ModiArt[VPU]#'
11 : </cfquery>
12 : </cfloop>

Also added an attachment so you guys can see what the filled table created by cfloop looks like

Well thx already for the help

Hope somebody can help me out with this

l8erz
Attached Images
File Type: jpg Plan_Edit.jpg (61.3 KB, 192 views)

Reply With Quote
  #2  
Old December 29th, 2004, 07:56 AM
Maximon Maximon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 2 Maximon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
small bug is fixed.... :) more to go ;)

Its me again

Now i got this far with my application.cfm File.

This is the new code:


Code:
<cfquery name="getVorplan" datasource="DARVorplan">
SELECT *
FROM Sendeplan
ORDER BY Sendeplan.Order
</cfquery>

<cfset Modi=listtoarray(selModerator,",")>
<cfset MArt=listtoarray(ModiArt,",")>

<cfloop index="VPU" from="1" to="#getVorplan.recordcount#">

<cfquery name="UpdateVorplan" datasource="DARVorplan">
UPDATE Sendeplan
SET Montag = '#Modi[VPU]#' , ArtMontag = '#MArt[VPU]#'
WHERE Sendeplan.Order = #VPU#
</cfquery>
</cfloop>



now i finally get all the djs in the fields where they are supposed to go to and it works.
So everything is nice and fancy up to the point where i want to change the Field Modi (in the main cfm file its a selectbox called ModiArt which gets converted to an array in the SPEdit.cfm with listtoarray) I get this kind of Error Message:

The element at position 3 of dimension 1, of array variable "MART," cannot be found.


The error occurred in ..\SPProcess.cfm: line 14

12 : <cfquery name="UpdateVorplan" datasource="DARVorplan">
13 : UPDATE Sendeplan
14 : SET Montag = '#Modi[VPU]#' , ArtMontag = '#MArt[VPU]#'
15 : WHERE Sendeplan.Order = #VPU#
16 : </cfquery>

Does anybody have an idea?



Thanks already

L8ers

Reply With Quote
  #3  
Old December 29th, 2004, 05:46 PM
glively glively is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 17 glively User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 51 sec
Reputation Power: 0
Are you sure your 2 lists MArt and Modi have the same number of elements? Sounds to me like one list has more elements than the other and you are stepping out of bounds. Also, if there are the same number of elements, are some elements blank? CF skips blank elements in a list. (i.e. they are not even counted) So if you have a list:

Yesterday,Today,,Tomorrow

You MIGHT think that this list has 4 elements. Nope, just 3 according to CF.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Update query problem including cfloop


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway