DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   ColdFusion (http://www.daniweb.com/forums/forum19.html)
-   -   I'm sure there is an easy Loop solution - doing an update (http://www.daniweb.com/forums/thread116863.html)

sanscls Apr 1st, 2008 6:17 pm
I'm sure there is an easy Loop solution - doing an update
 
I want to update an access db with multiple records. They are property pictures. They may have the same listnumber, but all have a different ID#. There are not always a set amount of pics... may be 5 or 7 or 10, etc..

The DB fields are id, filedata (actual .jpg filename), picturename, listnumber

I am trying to add names to all pictures at once instead of one at a time. Below is the code I have... it is only updating one record at a time.

Data entry page: (output query: lookup grabs the pictures witha a specific listnumber ie:1950)

<cfoutput query="lookup">
<form enctype="multipart/form-data" action="title_picture_action.cfm?id=#listnumber#" method="POST">
<input type="hidden" name="id" value="#id#">
<input type="hidden" name="listnumber" value="#listnumber#">

        <table border="0" width="500" cellpadding="10" cellspacing="0">
        <tr>
        <td><img src="images/uploads/#filedata#" width="100"></td>
                <td><input type="text" maxlength="50" size="20" name="picturename" value="#picturename#"></td>
                <!--- <td align="center"><input type="submit" value="Submit"></td> --->
               
                <hr color="00704a" style="height = 1px">
    </tr>
        </cfoutput>
        <tr><td><input type="submit" value="Submit"></form></td></tr>
        <table>

Processing page:

<cfquery name="titlepicture" datasource="#dsn#">
        UPDATE uploads SET       
        picturename = '#form.picturename#'
        WHERE id = #form.id#
        </cfquery>
                       
        <cflocation url="index.cfm

Any help will be GREATLY appreciated! Thx in advance.

sanscls Apr 2nd, 2008 9:01 am
Re: I'm sure there is an easy Loop solution - doing an update
 
To make clear: My problem is on the Processing page. I need to be able to update MULTIPLE images (filedatd field in db) with names (picturename field in db) They will have the SAME listnumber, but different ID numbers.

tashakota Apr 15th, 2008 2:09 pm
Re: I'm sure there is an easy Loop solution - doing an update
 
Quote:

Originally Posted by sanscls (Post 575092)
To make clear: My problem is on the Processing page. I need to be able to update MULTIPLE images (filedatd field in db) with names (picturename field in db) They will have the SAME listnumber, but different ID numbers.



I believe if you update the db using the listnumber instead of the id, then you should be updating all records with that listnumber.

ie:

cfquery name="titlepicture" datasource="#dsn#"
UPDATE uploads SET
picturename = '#form.picturename#'
WHERE listnumber = #form.listnumber#
cfquery
     
cflocation url="index.cfm

iqbalhosan Jun 3rd, 2008 5:43 am
try this!
 
<cfoutput>
        <form enctype="multipart/form-data" action="title_picture_action.cfm?id=#listnumber#" method="POST">
                <table border="0" width="500" cellpadding="10" cellspacing="0">       
                        <tr>       
                                <td><img src="images/uploads/#filedata#" width="100"></td>               
                                <td>
                                        <input type="text" maxlength="50" size="20" name="picturename" value="#picturename#">
                                        <input type="submit" value="Submit">
                                </td>
                        </tr>       
                </table>
        </form>
</cfoutput>       





###################processing page################


<cfquery name="titlepicture" datasource="#dsn#">
                UPDATE        uploads
                SET        picturename = '#form.picturename#'
                WHERE id = #url.id#
        </cfquery>


All times are GMT -4. The time now is 4:52 pm.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC