Advertisement
Advertisement
| 03.25.2008 at 05:50AM PDT, ID: 23266742 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: |
Here's the SQL...
CREATE TABLE `menu` (
`menuID` smallint(4) NOT NULL auto_increment,
`menuItem` varchar(64) collate latin1_general_ci default NULL,
`pageID` smallint(4) default NULL,
PRIMARY KEY (`menuID`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
INSERT INTO `menu` VALUES ('1', 'Blog', '1');
INSERT INTO `menu` VALUES ('2', 'Photos', '2');
INSERT INTO `menu` VALUES ('3', 'News', '3');
INSERT INTO `menu` VALUES ('4', 'Projects', '4');
CREATE TABLE `pages` (
`pageID` smallint(4) NOT NULL auto_increment,
`pagename` varchar(64) collate latin1_general_ci default NULL,
PRIMARY KEY (`pageID`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
INSERT INTO `pages` VALUES ('1', 'Blog');
INSERT INTO `pages` VALUES ('2', 'photos');
INSERT INTO `pages` VALUES ('3', 'News');
INSERT INTO `pages` VALUES ('4', 'Projects');
Now, here's the code..
<cfquery name="getPages" datasource="#APPLICATION.datasource#">
SELECT *
FROM pages
</cfquery>
<cfquery name="getMenu" datasource="#APPLICATION.datasource#">
SELECT *
FROM menu
</cfquery>
<cfform action="">
<table width="400" border="1px">
<tr>
<th>menu item</th>
<th>menu ID</th>
<th>pageID</th>
<th>pagename</th>
</tr>
<!--- output menu item as table row --->
<cfoutput query="getMenu">
<tr>
<td>#menuItem#</td>
<td>#menuID#</td>
<td>#pageID#</td>
<td>
<cfselect name="pageID_#getMenu.menuID#">
<cfloop query="getPages">
<option value="#getPages.pageID#"
<cfif #getPages.pageID# eq #getMenu.pageID#>
selected="selected"
</cfif>>#pagename#
</option>
</cfloop>
</cfselect>
</td>
</tr>
</cfoutput>
</table>
</cfform>
|