musicradiolive Posted August 3, 2006 Share Posted August 3, 2006 Hi. I am writing a reservation system for a theatre and need a quick bit of help with the table to shows the seats. I have got a database that has got the following tables: Seat ¦ Status ¦ (Customer info (for when they book the seat) In the seat one i put the seats (A1 - A10, B1 - B10 etc) I want A1 - A10 to appear on the first line, then start a new row and do B1 - B10 etc etc for as many rows as i want (it will only go up to T10, but it would be nice to know i can make it easily expandable should more seats be added)Here is the code i am using so far: --------------------------------------------------- strSQL = "SELECT tblSeats.Seat, tblSeats.Status FROM tblSeats;" rs.Open strSQL, adoCon Response.Write "<table width=700 border=0 align=center><tr>" While NOT rs.EOF If rs("status") = "Booked" Then col = "Red" Else col = "Green" End If Response.Write "<td><table width=80% border=1 align=center><tr><td bgcolor=""" & col & """><div align=center class=style3><font face=verdana><a href=make_booking.asp?seat=" & rs("seat") & ">" & rs("Seat") & "</a></font></div></td></tr></table></td>" rs.Movenext() Wend Response.Write "</tr></table>" Any help anyone can offer on this would be greatly appreciated.Thanks Link to comment Share on other sites More sharing options...
aspnetguy Posted August 3, 2006 Share Posted August 3, 2006 use something like this to check if it is on seat 10 of each row. If it is you know to start a new table row If InStr(rs('seat')) <> -1 Then 'start new row 'etcEnd If Link to comment Share on other sites More sharing options...
musicradiolive Posted August 3, 2006 Author Share Posted August 3, 2006 Thanks for your help, i got this : While NOT rsShow1Avail.EOF If sLetter <> Left(rsShow1Avail("seat"), 1) Then If sLetter <> "" Then Response.Write "</tr>" End If Response.Write "<tr>" sLetter = Left(rsShow1Avail("seat"), 1) End If If rsShow1Avail("status") = "Booked" Then col = "Red" Else col = "Green" End If This worked without any problems.The only thing i want to do now is create a gap down the middle.This HTML code demonstartes what i mean: <table width="100%" border="0" cellspacing="1" cellpadding="1"> <tr> <td>A1</td> <td>A2</td> <td>A3</td> <td>A4</td> <td>A5</td> <td rowspan="3"></td> <YOU CAN SEE I HAVE GOT A MERGED CELLS HERE TO CREATE THE GAP DOWN THE MIDDLE <td>A6</td> <td>A7</td> <td>A8</td> <td>A9</td> <td>A10</td> </tr> <tr> <td>B1</td> <td>B2</td> <td>B3</td> <td>B4</td> <td>B5</td> <td>B6</td> <td>B7</td> <td>B8</td> <td>B9</td> <td>B10</td> </tr> <tr> <td>C1</td> <td>C2</td> <td>C3</td> <td>C4</td> <td>C5</td> <td>C6</td> <td>C7</td> <td>C8</td> <td>C9</td> <td>C10</td> </tr></table> Link to comment Share on other sites More sharing options...
aspnetguy Posted August 3, 2006 Share Posted August 3, 2006 All you need to do is check if rs('seat') == "A5" and if it does create the row like the rest but after you create the row add the <td rowspan="3"></td> Link to comment Share on other sites More sharing options...
musicradiolive Posted August 3, 2006 Author Share Posted August 3, 2006 While NOT rs.EOF If sLetter <> Left(rs("seat"), 1) Then If sLetter <> "" Then Response.Write "</tr>" End If Response.Write "<tr>" sLetter = Left(rs("seat"), 1) End If If rs('seat') == "A5" Then Response.Write "<td rowspan=3></td>" End If If rs("status") = "Booked" Then col = "Red" Else col = "Green" End If Like that?????? It wont work, i get:Microsoft VBScript compilation (0x800A03EA)Syntax error/showavail.asp, line 39, column 16If rs('seat') == "A5" ThenI have obviously done something wrong!?!? Link to comment Share on other sites More sharing options...
aspnetguy Posted August 3, 2006 Share Posted August 3, 2006 oops try = instead of ==I am used to C# not VB sorry Link to comment Share on other sites More sharing options...
musicradiolive Posted August 3, 2006 Author Share Posted August 3, 2006 No worries mate Just so you know, i took what you said and tried it, didn't work.I noticed elsewhere in my script, when i have used rs( i have done rs(" no rs('So i put: rs("seat") = That kind of worked, the error went but the gap didn't appear so i put:[/code]if rs("seat") = "A5" Then Response.Write <td rowspan=3>H</td>" That way i can see where it's putting the H.It was putting the H BEFORE A5, so i simply changed it to A6 and the H appeared in the right place! All i had to do then was make the cell a Width i wanted.End result :[code] If rs("seat") = "A6" Then Response.Write "<td rowspan=3 width=40></td>" End If Note to anyone who uses the code: Make sure you change the rowspan=3 to however many rows will appear, otherwise it wont work correctly Thanks aspnetguy for your help, very much appreciated. WHOOOOOOOOOOOOOO *Passes aspnetguy a beer* Link to comment Share on other sites More sharing options...
aspnetguy Posted August 3, 2006 Share Posted August 3, 2006 *Passes aspnetguy a beer*I just might take if I drank but I don't...how about a pepsi? mmmm pepsi Link to comment Share on other sites More sharing options...
musicradiolive Posted August 3, 2006 Author Share Posted August 3, 2006 YOU DONT WANT THAT CHEAP STUFF!! EWWWWW*Passes aspnetguy A PROPER BRAND (Coca Cola {NOT DIET ETC}) Link to comment Share on other sites More sharing options...
aspnetguy Posted August 3, 2006 Share Posted August 3, 2006 Perhaps I had leave before further insults are made.... jkWell I will except your offering out of politeness. Thank you....*murmers under breathe* Link to comment Share on other sites More sharing options...
musicradiolive Posted August 3, 2006 Author Share Posted August 3, 2006 I am now setting up the reserve seat feature.One note i want to make to poeple, dont get fooled, you need to UPDATE the record, not make a new one (i done that originally and ended up adding more seats lol)I have just got this from w3schools: <%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "-----------------------------------------.mdb"cid=Request.Querystring("seat")if Request.Querystring("seat")="" then set rs=Server.CreateObject("ADODB.Recordset") rs.open "SELECT tblseats.seat, tblseats.status FROM tblseats WHERE seat='" & cid & "'",conn %> <form method="post" action="demo_update.asp"> <table> <%for each x in rs.Fields%> <tr> <td><%=x.name%></td> <td><input name="<%=x.name%>" value="<%=x.value%>"></td> <%next%> </tr> </table> <br /><br /> <input type="submit" value="Update record"> </form><%else sql="UPDATE seats SET " sql=sql & "seat='" & Request.Querystring("seat") & "'," 'sql=sql & "contactname='" & Request.Form("contactname") & "'," 'sql=sql & "address='" & Request.Form("address") & "'," 'sql=sql & "city='" & Request.Form("city") & "'," 'sql=sql & "postalcode='" & Request.Form("postalcode") & "'," 'sql=sql & "country='" & Request.Form("country") & "'" sql=sql & " WHERE seat='" & cid & "'" on error resume next conn.Execute sql 'if err<>0 then 'response.write("No update permissions!") 'else 'response.write("Record " & cid & " was updated!") 'end if end ifconn.close%></body></html> But for some reason all i got was Update Record as a heading, no form appeared, This is really annoying!I will admit, this is the first upodate record script i have used that hasn't produced an error, so i am part of the way there :)Oh, by the way aspnetguy, you dont work for pepsi do you? lmao!! Link to comment Share on other sites More sharing options...
aspnetguy Posted August 3, 2006 Share Posted August 3, 2006 is request.querystring("seat") = "" ??? If not the form will not show Oh, by the way aspnetguy, you dont work for pepsi do you? lmao!!Heck no...I work to buy Pepsi...among other things. Link to comment Share on other sites More sharing options...
musicradiolive Posted August 3, 2006 Author Share Posted August 3, 2006 Heck no...I work to buy Pepsi...among other thingsAmong other things.... mmmm, think best we leave that one there is request.querystring("seat") = "" ??? If not the form will not showOn the screen that shows the seats it generates a link called:<a href=bookseat.asp?seat=" & rs("seat") & ">" & rs("Seat") & "</a> Which then opens http://127.0.0.1/bookseat.asp?seat=A1I then want it to bring up the form for the customer to make the reservation.:::::::::: UPDATE ::::::::::mmm, interesting, i just thought i would have a quick mess around with the script, and i made the form come up. cid=Request.Querystring("seat")if Request.Querystring("seat")="" then set rs=Server.CreateObject("ADODB.Recordset") rs.open "SELECT tblseats.seat, tblseats.status FROM tblseats WHERE seat='" & cid & "'",conn %> GOT CHANGED TO: cid=Request.Querystring("seat")'if Request.Querystring("seat")="" then set rs=Server.CreateObject("ADODB.Recordset") rs.open "SELECT tblseats.seat, tblseats.status FROM tblseats WHERE seat='" & cid & "'",conn %> Notice how the if got a ' so it doesn't runI then had to put ' in the following parts to get rid of the traces: <%else sql="UPDATE seats SET " sql=sql & "seat='" & Request.form("seat") & "'," THAT BECAME <%'else sql="UPDATE seats SET " sql=sql & "seat='" & Request.form("seat") & "'," 'response.write("Record " & cid & " was updated!") 'end if end ifconn.close BECAME 'response.write("Record " & cid & " was updated!") 'end if 'end ifconn.close[code]The form then started appearing, i am now going to do the process page, so fingers crossed!! Link to comment Share on other sites More sharing options...
aspnetguy Posted August 3, 2006 Share Posted August 3, 2006 Thats because seat=A1 not ""change it to if Request.Querystring("seat")<>"" then Link to comment Share on other sites More sharing options...
musicradiolive Posted August 3, 2006 Author Share Posted August 3, 2006 Ok, that works too So i now got the form up, and i have got the process page written as well, but the update doesn't take place so obvilously another bit i gotta change, AGAIN!Have i missed a <> somewhere?? <html><head><title>ADO - Submit DataBase Record</title></head><body><h2>Submit to Database</h2><%on error resume nextset conn=Server.CreateObject("ADODB.Connection") conn.provider="Microsoft.Jet.OLEDB.4.0"conn.open(server.mappath("-------------------------------.mdb"))if Request.querystring("action")="Save" then seat=Request.Form("seat") sql="UPDATE tblseats SET status='" & Request.Form("status") & "'," sql=sql & "cust_forename='" & Request.Form("cust_forename") & "'," sql=sql & "cust_surname='" & Request.Form("cust_surname") & "'," sql=sql & "cust_book_id='" & Request.Form("cust_book_id") & "'," sql=sql & "cust_address='" & Request.Form("cust_address") & "'," sql=sql & "cust_postcode='" & Request.Form("cust_postcode") & "'," sql=sql & "cust_area_code='" & Request.Form("cust_area_code") & "'," sql=sql & "cust_tel_number='" & Request.Form("cust_tel_number") & "'," sql=sql & "cust_cc='" & Request.Form("cust_cc") & "'," 'sql=sql & "cust_cc='" & now() & "' WHERE tblseats.seat=" & no conn.Execute sql, Recordsaffected if err <> 0 then Response.Write("You do not have permission to update this database!") else Response.Write("Record number " & no & " was updated.") end if Response.Redirect("default.asp")end if'if Request.Form("action")="Delete" then 'no=Request.Form("no")' conn.Execute "DELETE FROM tblGuestBook WHERE tblGuestBook.[no]=" & no, Recordsaffected' if err <> 0 then' Response.Write("You do not have permission to delete a record from this database!")' else ' Response.Write("Record number " & no & " was deleted.")' end if 'Response.Write("Deleting records has been disabled from this demo")'end ifconn.close%></body></html> All i get is the heading again, so i go back to the main screen to see if the seat has turned red and it hasn't!GRRRRR lol Link to comment Share on other sites More sharing options...
aspnetguy Posted August 3, 2006 Share Posted August 3, 2006 comment out this line on error resume next it will hide the sql errors and will appear to work correctly. You should get an error ont he screen now.Problems like this are usually sql syntax errors Link to comment Share on other sites More sharing options...
musicradiolive Posted August 3, 2006 Author Share Posted August 3, 2006 didn't bring up an errors, just done the same thing again,however, i did make a slight change bearing in mind what you said earlier. if Request.querystring("action")="Save" then BECAME if Request.querystring("action")<>"Save" then and all of a sudden i got the errorMicrosoft JET Database Engine (0x80040E14)Syntax error in UPDATE statement./bookseat_process.asp, line 26Line 26 is: conn.Execute sql, Recordsaffected Link to comment Share on other sites More sharing options...
aspnetguy Posted August 3, 2006 Share Posted August 3, 2006 just to clarify <> means not equal too.What is the value of the querystring('action') that is passed to the processing page? because in the form action there is no querystring being sent. You can remove that If statement completely...it serves no purpose.Okay lets debug your sql.comment out line 26 to stop it from executing and giving us the error. underneath of it type Response.Write(sql) Post what you see on the screen after running the form again. Link to comment Share on other sites More sharing options...
musicradiolive Posted August 3, 2006 Author Share Posted August 3, 2006 perhaps i forgot to post this change: <form method="post" action="bookseat_process.asp?action=save"> So a query string is now being passed.No errors anymore, it just goes straight to the: Response.Write("Record number " & no & " was updated.") end if Response.Redirect("default.asp")end if and takes me straight back to the default.asp page Link to comment Share on other sites More sharing options...
aspnetguy Posted August 3, 2006 Share Posted August 3, 2006 so is it updating or still nothing is happaning???Try the thing s I suggested above and be sure to comment out the page redirection to so you can see the sql statement that will be written to the page Link to comment Share on other sites More sharing options...
musicradiolive Posted August 3, 2006 Author Share Posted August 3, 2006 i took out the redirect and got:Submit to DatabaseRecord number was updated. Went to the main screen and it hasn't updated it, so the script lies! lol Link to comment Share on other sites More sharing options...
aspnetguy Posted August 3, 2006 Share Posted August 3, 2006 did you do this? comment out line 26 to stop it from executing and giving us the error. underneath of it typeCODEResponse.Write(sql)Post what you see on the screen after running the form again. Link to comment Share on other sites More sharing options...
musicradiolive Posted August 3, 2006 Author Share Posted August 3, 2006 Line 26 is out because thats: ' conn.Execute sql, Recordsaffected I assume you mean: Response.Write("You do not have permission to update this database!") else Response.Write("Record number " & no & " was updated.") <<THIS LINE HERE ? end if 'Response.Redirect("showavail.asp")end if After taking that out out and obviously the else i dont get any errors come up Link to comment Share on other sites More sharing options...
aspnetguy Posted August 3, 2006 Share Posted August 3, 2006 aactually I meant do this ' conn.Execute sql, RecordsaffectedResponse.Write(sql) Then run the script and tell me what the sql statment is that is outputed Link to comment Share on other sites More sharing options...
musicradiolive Posted August 3, 2006 Author Share Posted August 3, 2006 UPDATE tblseats SET status='',cust_forename='',cust_surname='',cust_book_id='',cust_address='',cust_postcode='',cust_area_code='',cust_tel_number='',cust_cc='', Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now