1

Below is the code on my edit page. I want it to show only the data that I have clicked the edit button on. I click on one row only but then it shows all of the data. Can anyone see what's wrong with the code? I guess there must be some condition on the query, right? But then it shows all of the data.

<cfquery name="UpdateCity" datasource="test">                          
  Select name, countrycode, population
  from city
</cfquery>

This is the other page after I click the edit button:

enter image description here

Miguel-F
  • 13,450
  • 6
  • 38
  • 63
zedd-coder
  • 11
  • 2
  • 1
    you have to add code also not only result or error in question see this link https://stackoverflow.com/help/how-to-ask – Aryan Oct 01 '20 at 09:25
  • 3
    You are correct - your query needs a condition to limit the data results. You need to pass some index value when you click the row so the query only returns that one row's data. – Miguel-F Oct 01 '20 at 12:12
  • 3
    In addition to a filter, you probably want to select the primary key field of your table. City/country combinations are not necessarily unique. Also, it's rare, but cities do get renamed. Finally, you may need to give users the opportunity to correct spelling mistakes. – Dan Bracuk Oct 01 '20 at 12:18
  • @Miguel-F so what the condition do i need to put in the query in order to display only selected row after i click the edit button? – zedd-coder Oct 02 '20 at 01:03
  • 1
    Well that depends on your data. The best/fastest option is to use the primary key field from your table for each row as Dan mentioned. – Miguel-F Oct 02 '20 at 12:22

0 Answers0