SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question how to hide duplicate fields value in asp from, and print that data on printer

    i want to hide duplicate values of a column in a asp form, lets suppose i have a field schoolname, and studentname, so it is possible a school have so many studnets, so i dont want to show school name infront of each student name, how can i hide it, please help me
    Last edited by zami; Dec 1, 2006 at 02:00.

  2. #2
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How exactly are you displaying what you have at the minute?

  3. #3
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi
    I m showing data from access database's tables (2), which displaying well, but as i told u its repeating schoolname, as there are more then 1 student in a school, so i just want that school name appear only once, the database name is coming from another page,

    codes :
    <%

    uid= Request("UID")

    Response.Write " District "&UID&" Girsl Scholarship Data"
    session("database") = uid


    set conn=Server.Createobject("ADODB.Connection")
    sDatabaseFile = session("database") & ".mdb"
    sDatabasePath = Server.MapPath(sDatabaseFile)
    conStr = "provider=microsoft.jet.oledb.4.0;data source=" & sDatabasePath & ";persist security info = false;"
    Conn.Open conStr

    sqlschoolinfo = "SELECT student1.*, schoolinfo.* FROM student1 INNER JOIN schoolinfo ON student1.Semiscode = schoolinfo.Semiscode where student1.name <> '' "

  4. #4
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You didn't post the code that you are using to actually display this information, which would be helpful.

    If the data retreived is from the one school, you could display the field from the recordset before the loop that displays the data. In the loop, simply leave out the call to the field that contains the school name and just stick with the pupil field.

  5. #5
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ihitman
    You didn't post the code that you are using to actually display this information, which would be helpful.

    If the data retreived is from the one school, you could display the field from the recordset before the loop that displays the data. In the loop, simply leave out the call to the field that contains the school name and just stick with the pupil field.
    here is full codes for u : check it plese, and tell me where is fault. thanks

    <html>
    <head>
    <title>Data Status</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body bgcolor="#E9DFAB" link="#FF0000">

    <p>&nbsp;</p>
    <p align="center"><strong><font size="3" face="Verdana, Arial, Helvetica, sans-serif">Data View Form </font></strong><br>
    </p>

    <%

    uid= Request("UID")

    Response.Write " District "&UID&" Girsl Scholarship Data"
    session("database") = uid


    set conn=Server.Createobject("ADODB.Connection")
    sDatabaseFile = session("database") & ".mdb"
    sDatabasePath = Server.MapPath(sDatabaseFile)
    conStr = "provider=microsoft.jet.oledb.4.0;data source=" & sDatabasePath & ";persist security info = false;"
    Conn.Open conStr

    sqlschoolinfo = "SELECT student1.*, schoolinfo.* FROM student1 INNER JOIN schoolinfo ON student1.Semiscode = schoolinfo.Semiscode where student1.name <> '' "

    set rsschoolinfo =server.createobject("adodb.recordset")
    rsschoolinfo.open sqlschoolinfo,conn,2,1
    %>

    <table width="100%" border="1" cellspacing="0" cellpadding="0">
    <tr>
    <td width="23%" bgcolor="#FFFFFF"><p><strong><font size="2"><a href="Logoff.asp"><font color="#FF0000" face="Verdana, Arial, Helvetica, sans-serif">Click here to log off</font></a><font face="Verdana, Arial, Helvetica, sans-serif"> </font></font></strong></p></td>
    <td width="24%" bgcolor="#FFFFFF">&nbsp;<input type="button" value="print" onClick="window.open('viewdataprint.asp?print=true uid=uid','s','width=400px, height=600px');"></td>

    <td width="53%" bgcolor="#FFFFFF"><strong><font size="2"><font color="#FF0000" face="Verdana, Arial, Helvetica, sans-serif">


    </font></font></strong></td>
    </tr>
    </table>
    <strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">* Showing New School</font></strong> <br>

    <table width="92%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
    <tr>
    <td width="6%"><div align="center"><font color="#FFFFFF" size="1"><strong><font face="Verdana, Arial, Helvetica, sans-serif">SEMIS Code</font></strong></font></div></td>
    <td width="25%" bgcolor="#E9DFAB"><div align="center"><font color="#FFFFFF" size="1"><strong><font face="Verdana, Arial, Helvetica, sans-serif">School Name</font></strong></font></div></td>
    <td width="12%" bgcolor="#E9DFAB"><div align="center"><font color="#FFFFFF" size="1"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Student Name</font></strong></font></div></td>
    <td width="15%" bgcolor="#E9DFAB"><div align="center"><font color="#FFFFFF" size="1"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Father's Name </font></strong></font></div></td>
    <td width="8%" bgcolor="#E9DFAB"><font color="#FFFFFF" size="1"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Tehsil</font></strong></font></td>
    <td width="8%" bgcolor="#E9DFAB"><div align="center"><font color="#FFFFFF" size="1"><strong><font face="Verdana, Arial, Helvetica, sans-serif">UC</font></strong></font></div></td>
    <td width="7%" bgcolor="#E9DFAB"><div align="center"><font color="#FFFFFF" size="1"><strong><font face="Verdana, Arial, Helvetica, sans-serif">NIC No </font></strong></font></div></td>
    <td width="5%" bgcolor="#E9DFAB"><div align="center"><font color="#FFFFFF" size="1"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Class</font></strong></font></div></td>
    <td width="5%" bgcolor="#E9DFAB"><div align="center"><font color="#FFFFFF" size="1"><strong><font face="Verdana, Arial, Helvetica, sans-serif">GRNO</font></strong></font></div></td>
    <td width="9%" bgcolor="#E9DFAB"><div align="center"><font color="#FFFFFF" size="1"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Attendance<br>
    in (Days)</font></strong></font></div></td>
    <%
    do while not(rsschoolinfo.eof)
    %>
    </tr>
    <tr>
    <td><div align="left"><strong><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><%=rsschoolinfo("student1.semiscode")%></font></strong>
    <%if rsschoolinfo("schoolinfo.isnew")=true then %>
    <font color="#FF0000" size="1" face="Georgia, Times New Roman, Times, serif">*</font>
    <%else%>
    <%end if%>
    </div></td>

    <td><font color="#000000"><strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">
    <%=Rsschoolinfo("name")%>
    </font></strong></td>
    <td><strong><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><%=rsschoolinfo("fname")%></font></strong></td>
    <td><strong><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><%=rsschoolinfo("Tehsil")%></font></strong></td>
    <td><strong><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><% if rsschoolinfo("UC") <> "" then %> <%=rsschoolinfo("uc")%><%ELSE%> N/A<%end if%></font></strong></td>
    <td><strong><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><% if rsschoolinfo("fnic") <> "" then %> <%=rsschoolinfo("fnic")%><%ELSE%> N /A<%end if%></font></strong></td>
    <td><strong><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><% if rsschoolinfo("class") <> "" then %> <%=rsschoolinfo("class")%><%ELSE%>
    N/A
    <%end if%></font></strong></td>
    <td><strong><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><% if rsschoolinfo("grno") <> "" then %> <%=rsschoolinfo("grno")%><%ELSE%> N/A<%end if%></font></strong></td>
    <td><strong><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif">
    <% if rsschoolinfo("attendance") <> "" then %> <%=rsschoolinfo("attendance")%><%ELSE%> N/A <%end if%></font></strong></td>
    <%
    Response.Flush
    rsschoolinfo.MoveNext
    loop
    %>

    <%

    rsschoolinfo.Close
    set rsschoolinfo = Nothing
    conn.Close
    set conn = nothing
    %>
    </tr>
    <tr>
    <td height="26" colspan="10"><div align="center"></div></td>
    </tr>
    </table>
    </body>
    </html>

  6. #6
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dreamweaver user eh! Righto, replace the code sections below in the appropriate places...

    Code:
    sqlschoolinfo = "SELECT student1.*, schoolinfo.* FROM student1 INNER JOIN schoolinfo ON student1.Semiscode = schoolinfo.Semiscode where student1.name <> '' ORDER BY schoolinfo.[name]"
    
    ...
    
    <%
    Dim currentSchool, previousSchool
    do while not(rsschoolinfo.eof)
    	currentSchool = rsschoolinfo("name")
    %>
    
    ...
    
    <td><div align="left"><strong><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><%=rsschoolinfo("student1.semiscode")%></font></strong>
    <%if rsschoolinfo("schoolinfo.isnew")=true then %>
    <font color="#FF0000" size="1" face="Georgia, Times New Roman, Times, serif">*</font>
    <%end if%>
    </div></td>
    <td><font color="#000000"><strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">
    <%
    If currentSchool <> previousSchool Then
    	Response.Write currentSchool
    End If
    %>
    </font></strong></td>
    
    ...
    
    <%
    	Response.Flush
    	previousSchool = rsschoolinfo("name")
    rsschoolinfo.MoveNext
    loop
    %>
    Hope that helps.

  7. #7
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for your reply its working but not well, as its repeating school name, i m trying will tell u thanks again

  8. #8
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ensure you order your results by the school name so that all the pupils within the same school name get grouped together, that will make the example I gave above work better.


  9. #9
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Do you really need EVERY field from student1 table and EVERY field from schoolinfo table?
    Ian Anderson
    www.siteguru.co.uk

  10. #10
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Quote Originally Posted by ihitman
    Ensure you order your results by the school name so that all the pupils within the same school name get grouped together, that will make the example I gave above work better.

    i think its creating problem ORDER BY schoolinfo.[name]" i m here ordering data on name of student, instead of schoolname
    thanks for your reply

  11. #11
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by siteguru
    Do you really need EVERY field from student1 table and EVERY field from schoolinfo table?
    No, i just want if its print a school name then it print all students in that school, but dont repeate schoolname, till other schoolname.

  12. #12
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Now i want to print that data, how can i send this data on printer by clicking a buto

    yes i done now, and its working well. it was problem due to orderby, thx soo much, but now i want to print that data, or printer by clicking a button or word print, somene can tell me please
    Last edited by zami; Dec 1, 2006 at 00:04.

  13. #13
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Easiest way for this is to do a separate page that is contains the same data you require from the main page you are working on but without any styling or site navigation and so on, just enough layout detail to describe what the data shows.

  14. #14
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes i did it, but its saying no database there, as i m opening database through a variable. and comes from another page

  15. #15
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes i did it, but its saying no database there, as i m opening database through a variable. and comes from another page as i want user or my boss see this data and then press a button above to print report, and it can be print by entering two dates From... to...,


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •