Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display different items with the same table...

Status
Not open for further replies.

dip

Programmer
Aug 15, 2000
20
SG
Hai,

I have a problem where i can't display different items with the same table. I have a booking table where there are fields like date...time...name and etc. I have a field name sub_item_id in it too. I have another table where i have the description of this table and they are like below:-

sub_item_id sub_item_name item_id
1 conference room 1
2 projector 2
3 notebok 3

I could display the conference room details but i am not able to display the other items because i have not included the sub_item_id field in my query and it works but when i insert the sub_item_id for the projector i can't display the item. How should i do it?

Here is the code where i included the sub_item_id:

<cfloop from=&quot;1&quot; to=&quot;7&quot; index=&quot;ColCount&quot; >
<cfset theday=DateAdd(&quot;d&quot;,ColCount-1, CreateDate(year,month,day))>
<cfset thenextday=DateAdd(&quot;d&quot;,1, theday)>

<cfquery name=&quot;new_cal&quot; datasource =&quot;bookings&quot;>
select * from booking
where start_time BETWEEN #theday# AND #thenextday#
</cfquery>

<cfoutput><td bgcolor=&quot;blue&quot;>
<div align=&quot;left&quot;><font face=&quot;Arial, Helvetica, sans-serif&quot; size=&quot;2&quot; color=&quot;white&quot;>
<b>#DateFormat(theday,&quot;dd-mmm-yyyy&quot;)#
</div></td></cfoutput>
</cfloop>
</tr>

<cfset thistime=700>
<cfloop index=&quot;RowCount&quot; from=&quot;7&quot; to=&quot;23&quot;>
<tr align=&quot;right&quot; bgcolor=&quot;#FFFFCC&quot;>
<td>
<cfset thistime=thistime+30>

<cfoutput><b>
#timeformat(createtime(rowcount,0,0),&quot;hh:mm tt&quot;)#</cfoutput></td>
<cfset detect=0>
<cfloop from=&quot;1&quot; to=&quot;7&quot; index=&quot;ColCount&quot;>
<cfset theday=DateAdd(&quot;d&quot;,ColCount-1,CreateDate(year,month,day))>
<cfset first_hour=DateAdd(&quot;h&quot;,RowCount-detect,theday)>
<cfset last_hour=DateAdd(&quot;n&quot;,59,first_hour)>

<cfquery name=&quot;new_cal&quot; datasource =&quot;bookings&quot;>
select * from booking
where sub_item_id=2 and (start_time BETWEEN #first_hour#
AND #last_hour# )
</cfquery>

<cfif new_cal.RecordCount NEQ 0>
<cfoutput query=&quot;new_cal&quot;>
<td bgcolor=&quot;CCCCCC&quot;><a href=&quot;view1.cfm?bid=#b_id#&quot;>Booked</a>
</cfoutput>
<cfset detect=detect+1>
<cfelse>
<cfset detect=0>
<td>
</cfif>
 <cfoutput> </cfoutput>
</td>
</cfloop>

I am displaying my data in a table form...where my rows are time and my columns are date. The problem is if i were to take out the code sub_item_id=2 from the query below

select * from booking where sub_item_id=2 and (start_time BETWEEN #first_hour# AND #last_hour# )

then the information goes into the conference room data which i have saved as a different name. Well how do i display my information without interfering the other fields.

Regards,
Dip.






 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top