hi,
have the following mysql tables
book
bookid slotid date carid
1 1 20060602 1
1 2 20060602... 3
mottimes
id mott slotid
1 9:00 1
2 10:00 2
3 11:00 3
am making a query that lists All mot times in a table
and puts the car that is having an mot in the correct row in the table.
the problem im having is that i want all times in mottimes to be listed regardless if there is a record in book.
I want this so that someone can choose a time from the list and add a booking for that time.
another issue i am having is getting the standard date format coverted to yyyymmdd to use in the sql query.
so far...
have the following mysql tables
book
bookid slotid date carid
1 1 20060602 1
1 2 20060602... 3
mottimes
id mott slotid
1 9:00 1
2 10:00 2
3 11:00 3
am making a query that lists All mot times in a table
and puts the car that is having an mot in the correct row in the table.
the problem im having is that i want all times in mottimes to be listed regardless if there is a record in book.
I want this so that someone can choose a time from the list and add a booking for that time.
another issue i am having is getting the standard date format coverted to yyyymmdd to use in the sql query.
so far...
Code:
<%
'conn string
motdate = Request.QueryString("date")
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str
'mot1sql
motsql1 = "SELECT mot.mott, mot.motslot, car.reg, book.bookdate, cus.fname, cus.lname, cus.pcode, cus.cusid "_
& "FROM book "_
& "RIGHT JOIN mottimes AS mot ON mot.motslot = book.slotid "_
& "INNER JOIN car ON car.carid = book.carid "_
& "INNER JOIN cus ON cus.cusid = car.cusid "_
& "WHERE mot.dayid =1 "_
& "AND mot.bayid =1 "_
& "AND book.bookdate = '[motdate]'"
'open rs
Set rsmot1 = Server.CreateObject("ADODB.Recordset")
rsmot1.CursorLocation = 3
rsmot1.Open motsql1, conn, 1, 2
'html
<table>
<tr>
<td colspan="3" class = mfitsml>Mot Booking - Bay 1</td>
</tr>
'loop values
<%
Do While (Not rsmot1.Eof)
'rsmot1.movefirst
x_mottime1 = rsmot1("mott")
x_reg = rsmot1("reg")
x_bookdate = rsmot1("bookdate")
x_fname = rsmot1("fname")
x_lname = rsmot1("lname")
x_pcode = rsmot1("pcode")
x_cusid = rsmot1("cusid")
%>
<tr>
<td class = mfitsml><%response.write x_mottime1%></td>
<%
'if no record mark time as free
if isnull(x_cusid) OR x_cusid = "" then %>
<td class = mfitsml>FREE</td>
<% else
'or put in details of existing booking
%>
<td class = mfitsml><%response.write x_reg & " - " & x_fname & " " & x_lname & " " & x_pcode & x_bookdate%>
<%end if%>
</td>
<%
'link to enter new booking
if isnull(x_cusid) OR x_cusid = "" then %>
<td class = mfitsml>
<a href=<%Response.Write "custaddmot.asp?motdate=" & Server.URLEncode(motdate)%> target="_blank" onClick="
window.open(this.href, this.target, 'height=380,width=600,status=yes,resizable=yes');
return false;">Book></a>
</td>
<%else
'if booking exists add link to change
%>
<td class = mfitsml>
<a href=<%Response.Write "custaddmot.asp?key=" & Server.URLEncode(x_cusid) & "&motdate=" & Server.URLEncode(motdate)%> target="_blank" onClick="window.open(this.href, this.target, 'height=380,width=600,status=yes,resizable=no');return false;">Change></a>
</td>
<%end if%>
</tr>
<%
'loop rs
rsmot1.MoveNext
Loop
%>
</table>