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:
  #1  
Old July 26th, 2004, 08:22 PM
jordonbedwell jordonbedwell is offline
Ultra Geek!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 294 jordonbedwell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 19 sec
Reputation Power: 5
Help with selecting records in MYSQL

Hello,

I am trying to select sepecific records based on a check box. I am doing this for the admin area of my site.

For example they have all the pages listed down below, they can select edit or delete, I have that setup, but now I want to be able to SELECT a SPECIFIC recordset. Like the records for the page home.

Structure of menu (tablename: pages)
ID (int) (autoincrement) (primary)
LINK_NAME (varchar) (50)
PAGE_LINK (varchar) (100)
SORT_ORDER (varchar) (50)


Here is the code I use to create the part where they can select the page to edit.

<cfloop query="qGetPages">
<tr>
<td height="20" align="left" valign="middle"><cfoutput><a href="#qGetPages.page_link#">#qGetPages.link_name#</a></cfoutput></td>
<td align="center" valign="middle"><input name="edit" type="checkbox" id="edit" value="edit"></td>
<td align="center" valign="middle"><input name="delete" type="checkbox" id="delete" value="delete"></td>
</tr>
</cfloop>


Here is the part to do the query:


<cfif isdefined("go")>
<cfif isdefined("form.edit")>

</cfif>
<cfif isdefined("form.delete")>
<!--- This will be the query to delete --->
</cfif>
<!--- THis will be the query to edit --->
</cfif>



Here is one example record in the db in table pages.

ID = 1
LINK_NAME = HOME
PAGE_LINK = fuse.cfm?page=home
SORT ORDER = 1


Should I add hidden fields with values of the colums, however I still wouldnt know how to do the SQL query.

Examples would be greatful.

Thank you Much

Jordon Bedwell
Coldfusion Zone

Reply With Quote
  #2  
Old October 28th, 2004, 08:08 PM
jimmart jimmart is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 3 jimmart User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Return the ID of the page as the checkbox value.

The new code looks like this:

<cfloop query="qGetPages">
<tr>
<td height="20" align="left" valign="middle"><cfoutput><a href="#qGetPages.page_link#">#qGetPages.link_name#</a></cfoutput></td>
<td align="center" valign="middle"><input name="edit" type="checkbox" id="edit" value="#ID#"></td>
<td align="center" valign="middle"><input name="delete" type="checkbox" id="delete" value="#ID#"></td>
</tr>
</cfloop>

This will return FORM.edit and FORM.delete as lists. You can then use cfloop to do your query like so:

<cfif isdefined("FORM.edit")>
<cfloop index="ID" list="#FORM.edit#">
<cfquery name="edit" datasource="yourdsn">
SELECT * from pages where ID = #ID#
</cfquery>
</cfloop>
</cfif>

Remember to replace yourdsn the the name of you datasource.

As for your question "I still wouldnt know how to do the SQL query", I would need to know what you are trying to get from the DB.

Reply With Quote
  #3  
Old October 29th, 2004, 08:12 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,676 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 10 m 34 sec
Reputation Power: 53
Also (and I've been saying this a lot lately), I have to point out that this is really basic SQL stuff. It seems like a lot of people are just bypassing their assimilation of SQL knowledge and just trying to leap straight to coding an application. Let me save you a lot of frustration: if this sort of query is giving you trouble, then stop right now and go buy either Ben Forta's "SQL in 10 Minutes" or Ben's "ColdFusion MX Web Application Construction Kit". I'm telling you that without basic SQL knowledge you're not going to be able to do anything and you're constantly going to be bumping into this wall.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Help with selecting records in MYSQL


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 6 hosted by Hostway