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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

showing multiple records on page to relate to user

Status
Not open for further replies.

rjn2001

Programmer
Dec 29, 2004
172
GB
Good afternoon,

I ahve the following page, which I want the presentation to appear as the code says. However, I also want an if statement to carry out the displaying of the data. The IF statement is shown below the first code.

How can I insert the IF statement so that the page appears as I want it to?

Code:
<%@ LANGUAGE="VBSCRIPT" %>
<!--#include file="common.asp" -->
<% 

'File: profile.asp
'Description: Profile Page

Dim strSQL 		'Database query sring
Dim strUserName 'Holds the user name
Dim strFirst_Name 'Holds the user First Name
Dim User2		' Who Sees the Profile
Dim Rand 		' Random Key
Dim JobStart	'Job Start Date
Dim JobFinsih 	'Job Finish Date
Dim EmployerName	'Employer name

strUserName = Request.QueryString("UserID")
strFirst_Name = Request.Form("First_Name")
User = Request.QueryString("User2")
rand = Request.Cookies("Zone")("Key")
JobStart = Request.Form("JobStart")



if strUserName = "" then
strUserName = Request.Cookies("Zone")("UserID")
if NOT rand = Request.Cookies("Zone")("Key") OR strUserName= "" then
response.redirect("cookie.asp?rm=expire&.rand=" & rand & "") 
End if
End If


set conn = Server.CreateObject("ADODB.Connection")
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open "D:/Websites/richard/admin/db/users.mdb"

strSQL = "Select * From tblProject WHERE UserID ='" & strUsername & "'"
Set rsCheckUser = conn.Execute(strSQL)





%>
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns="[URL unfurl="true"]http://www.w3.org/TR/REC-html40">[/URL]
</style>
<link rel="stylesheet" type="text/css" href="css.css">
<script language="JavaScript" src="menu.js"></script>
<xml><o:shapedefaults v:ext="edit" spidmax="1027"/>
</xml>
<body>

    <p align="center">
<h1>
<img height="110" src="images/BARLogo.gif" width="125" border="0">Blue Resourcing - Project Profile</h1>
      <h2><%= strFirst_Name %>(Logged in as <%= strUsername %>)</h2>
      <table cols="2" width="500" cellspacing="0" cellpadding="0" border="0">

<%
If NOT rsCheckUser.EOF Then
  While NOT rsCheckUser.EOF
    strUserName = rsCheckUser("UserID")    

    If strUserName <> strOldUserName Then
      Response.Write "<tr><td colspan='2'><h2>" & strUserName & "</h2></td></tr>" & vbcrlf
    End If
%>
<table border="1" bordercolor="#000000" width="988">
<tr>
<th align="left" width="13%" bgcolor="#70B2D1">Start Date</th>
<th align="left" width="15%" bgcolor="#70B2D1">End Date</th>
<th align="left" width="69%" bgcolor="#70B2D1">Organisation Name</th>
</tr>
<tr>
<td align="left" width="13%"><%= rsCheckUser("ProjStart")%></td>
<td align="left" width="15%"><%= rsCheckUser("ProjFinish")%></td>
<td align="left" width="69%"><%= rsCheckUser("EmployerName")%></td>
</tr>
<th align="left" width="30%" colspan="3" bgcolor="#70B2D1" height="20">Your Role</th>
<tr>
<td align="justify" width="30%" colspan="3" valign="top"><%= rsCheckUser("ProjRole")%></td>
</tr>
<tr>
<th align="left" width="30%" colspan="3" bgcolor="#70B2D1">Project Details</th>
<tr>
<td align="justify" width="30%" colspan="3" valign="top"><%= rsCheckUser("ProjDetail")%></td>
</tr>

</table>
         
<form method="POST" action="edit_ProjectProfile.asp?.rand=<%= Md5Hash %>">
<input type="button" value="Cancel &amp; Return To Main Menu" onClick="history.go(-1)">
<%

    response.write("<input id='key' type ='hidden'  name='key' value='"&rsCheckUser("key")&"' />")
response.write("<input id='ProjStart' type ='hidden'  name='ProjStart' value='"&rsCheckUser("ProjStart")&"' />")
response.write("<input id='ProjFinish' type ='hidden'  name='ProjFinish' value='"&rsCheckUser("ProjFinish")&"' />")
response.write("<input id='EmployerName' type ='hidden' name='EmployerName' value='"&rsCheckUser("EmployerName")&"' />")
response.write("<input id='ProjRole' type ='hidden'  name='ProjRole' value='"&rsCheckUser("ProjRole")&"' />")
response.write("<input id='projDetail' type ='hidden' name='ProjDetail' value='"&rsCheckUser("ProjDetail")&"' />")
response.write("<input type='submit' name='edit' value='Click here to edit or delete this record' />")
response.write("</form>")
    strOldUserName = strUserName
    rsCheckUser.MoveNext
  Wend
Else
  Response.Write "<tr><td colspan='2'><p>No records found</p></td></tr>" & vbcrlf
End If

Set rsCheckUser = Nothing

conn.Close
Set conn = Nothing
%>
</table>
<table height="44" width="100%" align="left" id="table1">
	<tr>
		<td align="right" width="50%" height="40">
&nbsp;<tr>
				<td height="19"><a href="reset_cookie.asp">Login Panel</a> | Submission Form 
				| <a href="edit.asp">Edit your Account</a> </td>
			</tr>
		
		</td>
	</tr>
<tr>
  <td width="250"></td>
  <td width="250"></td>
</tr>
<tr>
	<td>&nbsp;</td>
</tr>

<font face="Arial" size="2">


</font>&nbsp;</P>

<!-- #include file="footer.asp" -->


<%
 'Close Objects
Set adoCon = Nothing
Set strCon = Nothing
Set rsCheckUser = Nothing
%>

The IF statement code:

Code:
<%
If NOT rsCheckUser.EOF Then
  While NOT rsCheckUser.EOF
    strUserName = rsCheckUser("UserID")    

    If strUserName <> strOldUserName Then
      Response.Write "<tr><td colspan='2'><h2>" & strUserName & "</h2></td></tr>" & vbcrlf
    End If

    Response.Write "<td><p>" & rsCheckUser("JobStart") & "</p></td><td><p>" & rsCheckUser("JobFinish") & "</p></td><td><p>" & rsCheckUser("EmployerName") & "</p></td><td><p>" & rsCheckUser("JobRole") & "</p></td><td><p>" & rsCheckUser("JobDetail") & "</p></td></tr>"

    strOldUserName = strUserName
    rsCheckUser.MoveNext
  Wend
Else
  Response.Write "<tr><td colspan='2'><p>No records found</p></td></tr>" & vbcrlf
End If

Set rsCheckUser = Nothing

conn.Close
Set conn = Nothing
%>
I am aware that the two lots of field names etc dont match, but I posted the page as it is my cleanest code.

Thanks in advance for any help provided.


Richard Noon
 
You already have an IF statement that determines the presentation in the first code.

In fact, is is exactly the same IF statement that you suggest in your second code.

From looking at the code that you posted, it looks like perhaps you wish to replace the CONTENT within the IF statement.

The first code contains an HTML table and a form that will be written for each record in the recordset.

The second code contains only some rows of an HTML table. Also it looks like perhaps you are missing a <tr> tag in the second code.

So what is the question? Please be more specific.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top