3 Replies Latest reply on May 28, 2006 11:29 PM by ShapeShift

    WHERE CLAUSE

    JohnGree Level 1
      Hi can someone help me i have a output of names with a button next to each of them, when the form is submited i have a action page that inserts information into a table

      the problem i have is when the form is submitted the whole output is being put into one record and they should be seperate records for each output row, i know i need to put a where clause in but not sure how to?

      EG
      name 1 submit
      name 2 submit

      so if i click submit next to name 1 only name 1 will be inserted into the table

      **FORM**
      <form name="form1" method="post" action="insertnewmember.cfm">
      <tr>
      <td><strong>Users Name </strong></td>
      <td><div align="left"><strong>Type of User </strong></div></td>
      <td><div align="center"><strong>Authorise This User </strong></div></td>
      </tr>
      <cfoutput query="Gettuserslist">
      <tr>
      <td width="276" height="31"> #Gettuserslist.Name#
      <input type="hidden" name="Name" value="#Gettuserslist.Name#">
      <input type="hidden" name="EmailAddress" value="#Gettuserslist.EmailAddress#">
      <input type="hidden" name="Password" value="#Gettuserslist.Password#">
      <input type="hidden" name="ID" value="#Gettuserslist.TempID#">
      </td>
      <td width="109"><div align="left">
      <select name="Type">
      <option>User</option>
      <option>Aministrator</option>
      </select>
      </div></td>
      <td width="72"><div align="center">
      <input name="submit" type="submit" value="Authorise">
      </div></td>
      </tr>
      <tr>
      <td height="20"> </td>
      <td> </td>
      <td> </td>
      </tr>
      </cfoutput>
      </form>

      **ACTION**
      <cfquery name="Insertuser2" datasource="Cricket">
      INSERT INTO PlayersList_Table
      (PlayersName, Email, Username, Password, Type)
      VALUES
      ('#form.Name#', '#form.EmailAddress#', '#form.EmailAddress#', '#form.Password#', '#form.Type#')
      </cfquery>
        • 1. Re: WHERE CLAUSE
          ShapeShift
          The Problem you are haiving is that on your form had for example 15 hidden values called "name" that is why it is inserting them all in one entry as perhaps, john,johan,mandy etc.

          You will have to make the=m dynamic like
          in your aotput statement, create variable counter and add 1
          cfinput type hidden name="Name#counter#"

          than on the action page check if more than i name is supplied
          • 2. Re: WHERE CLAUSE
            JohnGree Level 1
            hi thanks

            is this all i need to add?
            <input type="hidden" name="Name#counter#">

            or does it need a value? if so how do i create a counter
            • 3. Re: WHERE CLAUSE
              ShapeShift Level 1
              i have got a better idea for you. rather do this to your code, it will create an individual form, for each person, and you leave your action page as is
              forgot inside query, set counter = counter+1
              add above form field
              hope this works